You need to sign in to do that
Don't have an account?
Nitish Agrawal
Unexpected Identifier Error - Custom Button to invoke Apex Code
Hi All,
I am trying to invoke Apex code from custom button on a custom object (Trainee__c) page layout. I am getting error : Unexpected Identifier when I am passing the name field of the custom object in he parameter to Apex method. Following is the code:
I am also able to see the correct alert message with {!Trainee__c.Name}
Not sure where the problem is.
Following is my Apex Class and method
alert('Module Data for {!Trainee__c.Name} refreshed');
I am trying to invoke Apex code from custom button on a custom object (Trainee__c) page layout. I am getting error : Unexpected Identifier when I am passing the name field of the custom object in he parameter to Apex method. Following is the code:
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")} sforce.apex.execute("PopulateTraineeModule","PopulateTraineeModuleData", {TraineeName:{!Trainee__c.Name}); alert('Module Data for {!Trainee__c.Name} refreshed');If I replace {!Trainee__c.Name} with a hard coded value.. Say 'Atticus Finch' the logic is working fine.
I am also able to see the correct alert message with {!Trainee__c.Name}
Not sure where the problem is.
Following is my Apex Class and method
global class PopulateTraineeModule { webservice static void PopulateTraineeModuleData (String TraineeName ) { ... } }
alert('Module Data for {!Trainee__c.Name} refreshed');
If that doesn't work, declare a variable and pass that variable. See below example:
All Answers
If that doesn't work, declare a variable and pass that variable. See below example:
This code isn't throwing any errors. However, I am still not getting the desired outcome.
I am able to get the outcome if I hardcode the parameter value in the called method body and execute through debug.
Is there any way by which I can see the complete processing in debug view or joblog kind of thing.. Just wondering? Wanted to see what valus is being received by my method (I am new to salesforce)
Button Click>>Javascript>>Apex Method