+ Start a Discussion
Kaybee011Kaybee011 

Javascript button cancel button Saves record

Hi,

Need assistance with Javascript button that should convert record from Record type A to B.  If user clicks the Cancel on the Edit screen, the record is saved anyway.

How do I load the page back to previus view page if user Cancels?

Code below:

{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")} 

var caseObj = new sforce.SObject("Case"); 
caseObj.Id = '{!Case.Id}'; 
caseObj.RecordTypeId = '012D00000003I73'; 
var result = sforce.connection.update([caseObj]); 

if(result.success = 'true'){ 
parent.frames.location.replace("/"+caseObj.Id+"/e?retURL=%2F"+caseObj.Id+""); 
}else{ 
*I assume the window reload function here?*
}

*It goes without saying that I'm new to this*

Thanks in advance.
SandhyaSandhya (Salesforce Developers) 
Hi Kaybee011,

I have not tried but seen in some posts that this would work try it if that can help you.
window.history.back();

Please refer below links for more information on the simiar requirement.

http://salesforce.stackexchange.com/questions/1717/naviagate-to-previous-page-or-close-the-window
 
http://stackoverflow.com/questions/8067510/onclick-javascript-to-make-browser-go-back-to-previous-page
 
Hope this helps you!

Please mark it as Best Answer if my reply was helpful. It will make it available for other as the proper solution.
 
Thanks and Regards
Sandhya