You need to sign in to do that
Don't have an account?
George Adams
Trouble with JavaScript Button
I'm trying to create a custom button that will appear on every case. It will allow the current user to click it and take ownership of the case.
This is the code I'm using (which I basically copied from the button I have for this same purpose on the Contact):
When I click the button, I get the error: "Unexpected token case"
Anyone know what I'm doing wrong here?
Thanks!
This is the code I'm using (which I basically copied from the button I have for this same purpose on the Contact):
{!requireScript("/soap/ajax/33.0/connection.js")} var case = new sforce.SObject("Cases"); case.id = '{!Case.Id}'; case.ownerId= '{!$User.Id}'; var result = sforce.connection.update([case]); if (result[0].success=='false') { alert(result[0].errors.message); } else { location.reload(true); }
When I click the button, I get the error: "Unexpected token case"
Anyone know what I'm doing wrong here?
Thanks!
1) Change variable name to non key word
2) try this var newCase= new sforce.SObject("Case");
Refer to https://success.salesforce.com/answers?id=90630000000hRFsAAM
All Answers
1) Change variable name to non key word
2) try this var newCase= new sforce.SObject("Case");
Refer to https://success.salesforce.com/answers?id=90630000000hRFsAAM
Here's the code that works for anyone seeing this in the future: