You need to sign in to do that
Don't have an account?
George Adams
"Unexpected identifier" error from Detail Page Button
Hi all,
I'm creating a Detail Page Button that runs through various methods in an apex class. To get it up and running, I'm simply trying to return the current caseID in a pop-up. Here's the button code I'm using:
And here is the apex class:
When I click the button, I just get the error: "Unexpected identifier"
I posted both because I'm not sure if this is a problem with my javascript or apex code. There's also that unused method doMath in the class.
Eventually I want the apex class to (1) update a field on the current case (change Status to 'Closed'), (2) open the case email attachments associated with the current case in a new window, (3) create a record in a custom object with some info already filled out (based on some fields on the case), and (4) copy the case email attachments associated with the current case to the newly created record.
I'm assuming most of the above is outside the scope of this question, but I'm trying to get started on that path.
And help is appreciated. Thanks!
I'm creating a Detail Page Button that runs through various methods in an apex class. To get it up and running, I'm simply trying to return the current caseID in a pop-up. Here's the button code I'm using:
{!REQUIRESCRIPT("/soap/ajax/14.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/14.0/apex.js")} var thisCase = {!Case.Id}; var result = sforce.apex.execute( "logHearingResult", // class "changePriority", // method {currentCase: thisCase}); // method arguments alert(result + " is the current caseID."); //response
And here is the apex class:
global class logHearingResult{ WebService static Integer doMath(Integer number1, Integer number2) { integer mathResult; mathResult = number1 + number2; return mathResult; } WebService static Id changePriority(Id currentCase) { Set<Id> caseIds = new Set<Id>(); caseIds.add(currentCase); List<Case> results = [ select Id from Case where Id in :caseIds ]; id caseIdToReturn; caseIdToReturn = results.get(0).Id; return caseIdToReturn; } }
When I click the button, I just get the error: "Unexpected identifier"
I posted both because I'm not sure if this is a problem with my javascript or apex code. There's also that unused method doMath in the class.
Eventually I want the apex class to (1) update a field on the current case (change Status to 'Closed'), (2) open the case email attachments associated with the current case in a new window, (3) create a record in a custom object with some info already filled out (based on some fields on the case), and (4) copy the case email attachments associated with the current case to the newly created record.
I'm assuming most of the above is outside the scope of this question, but I'm trying to get started on that path.
And help is appreciated. Thanks!
No need to remove the post. It will help others having same issue so you could mark it as solved instead.
Just putting some explaination to your solution.
this statement in Datiled Button java script execution was giving exception. So it was givng you error message "Unhandled Exception".
Solution for this is to have assinged values in quotes like
In order get proper error message you could do Exception Handling in Java Script like
Thanks
Shashikant
All Answers
...to this:
I can remove the post if necessary.
If anyone knows were I might get started on the other aspects of the apex class, please let me know!
Thanks.
No need to remove the post. It will help others having same issue so you could mark it as solved instead.
Just putting some explaination to your solution.
this statement in Datiled Button java script execution was giving exception. So it was givng you error message "Unhandled Exception".
Solution for this is to have assinged values in quotes like
In order get proper error message you could do Exception Handling in Java Script like
Thanks
Shashikant