Important Update: Community URLs redirect issues are partially resolved. Learn More. .

cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Object - Close Button

syedtahir16
Advocate

I'm trying to create a custom object to close the record

 

<a class="tb-btn-link-left" id="CloseRecord" onclick="javascript:__doPostBack('', 'recordClose');" data-check-dirty="true"><div class="tb-btn" data-icon="&#xe366;" data-icon-pos="left">Close</div></a> 

 

Issue:

Click on Add new record: key in a few of the fields then click on Close record. The record closes fine. Now when I navigate to another workspace, it shows a popup warning that I have unsaved changes.

 

Same happens when i make a change to an existing record.

24 REPLIES 24

It also doesnot work, if I open an existing record and click on it. I'm just wondering what special flags the original X button is checking.

Well, again, works for me in existing records

Arun.Prasad
Advocate II

How about this one within your button click function?

 

$('.frame-icon-close').click();

You can not do it, it is a link with no event handler. 

Gotcha..  Thanks for correcting..

syedtahir16
Advocate

Ilya Khen

 

The only way I could get it to work was by doing this. I just want to check with you if this is a clean approach or not:

 

<script>
function closeRecord(){
$('.frame-icon-close').click();
javascript:CloseRecord('recordClose');
}
</script>

<input type="button" name="Close_Record" value="Close" onclick="javascript:closeRecord();">

That is definitely not a clean code. 1st half of the function is total overhead, as not working.

 

2nd part is the initial proposal of mine, which you said did not work for you. And now you claim it works interesting, but well, if this works, then do not touch, like any developer would say

 $('.frame-icon-close').click(); --> This works for me when we add a new record but don't fill in any fields. But does not throw the warning when I fill in any fields.

 

javascript:CloseRecord('recordClose'); --> This gives me a warning when I fill out/change any fields. But does not work when I Add a new record and do not fill out any fields.

Adding them both to the same function kinda works. But I know its not clean. I have just not been able to figure out why it works this way.

I've noticed the same behavior when deleting a questionnaire .  I create questionnaire , don't add anything to it because I realize I don't need it.  I delete it.  I'm moved back to the parent record.  I leave the parent record and I'm prompted to save the questionnaire I just deleted.

Well, I am saying that unless you do some event handler mapping, click should not work.

But anyway, it works, so do not touch