You need to sign in to do that
Don't have an account?
Steve Cairney
Additional alert on click javascript button after submission
I have a simple button that when clicked, cheanged the record type of the Opportunity in order to fire an email alert.
However, I'd like to add a query so that if the button has already been clicked, another alert will show to the user.
Would it be possible for the button to check the RecordTypeID and if the record has alredy been changed to 01220000000ML20, the alternative alert is shown.
Here's what I've tried, but the syntax isn't correct. Any tips?
{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")} var oppObj = new sforce.SObject("Opportunity"); oppObj.Id = '{!Opportunity.Id}'; oppObj.RecordTypeId = '01220000000ML20'; var result = sforce.connection.update([oppObj]); if (result[0].success=='false') { alert(result[0].errors.message); } else { alert("Success, Admin have been notified."); location.reload(true); }
However, I'd like to add a query so that if the button has already been clicked, another alert will show to the user.
Would it be possible for the button to check the RecordTypeID and if the record has alredy been changed to 01220000000ML20, the alternative alert is shown.
Here's what I've tried, but the syntax isn't correct. Any tips?
{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")} var oppObj = new sforce.SObject("Opportunity"); oppObj.Id = '{!Opportunity.Id}'; oppObj.RecordTypeId = '01220000000ML20'; var result = sforce.connection.update([oppObj]); if ({oppObj.RecordTypeId = '01220000000ML20'; )} {alert("This has already been approved."); location.reload(true);} ){ else if (result[0].success=='false') { alert(result[0].errors.message); } else { alert("Success, Admin have been notified."); location.reload(true); }
Hardcoding Id is badpractice. Replace PUT_RECORD_TYPE_NAME_HERE with record type name.
Am I right in thinking that line 10 should be records.RecTypeId?
Sorry it was by mistake