You need to sign in to do that
Don't have an account?

I created a javascript button and passing Account ID and calling apex classes ...
I created a javascript button and passing Account ID and calling apex classes .When i click on button on account detail page am getting the Error when i press that button like "A Problem with this button or link was Encountered Unexpected Identifier"
Button:
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}
if({!Account.Name}!=Null)
{
sforce.apex.execute("SandvineCreateUpdateSAPAccount","createupdateSAPAccount",{!Account.Id}"});
alert("This is {!Account.Name}");
}
Why am getting this error ...this button send the account ID to the external URL
Button:
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}
if({!Account.Name}!=Null)
{
sforce.apex.execute("SandvineCreateUpdateSAPAccount","createupdateSAPAccount",{!Account.Id}"});
alert("This is {!Account.Name}");
}
Why am getting this error ...this button send the account ID to the external URL
Try the below code:
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}
alert('hi');
if('{!Account.Name}'!= null)
{
alert('hello');
var AccountId='{!Account.Id}';
sforce.apex.execute("SandvineCreateUpdateSAPAccount","createupdateSAPAccount",{AccountId: AccountId});
}
Note: The text in bold and italic "AccountId" is assumed as the parameter name you declared for method createupdateSAPAccount., like:
webservice static void createupdateSAPAccount(Id AccountId)
So if you have any other variable name over there is method specify it in the highlighted area.
All the merge fields should be in quotes, and for usage of sforce.apex.execute statement please refer to below link:
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_and_ajax.htm
If it anwers your question, please to vote this as Best Answer.
Hope it helps:
Thanks,
Balaji
All Answers
Try the below code:
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}
alert('hi');
if('{!Account.Name}'!= null)
{
alert('hello');
var AccountId='{!Account.Id}';
sforce.apex.execute("SandvineCreateUpdateSAPAccount","createupdateSAPAccount",{AccountId: AccountId});
}
Note: The text in bold and italic "AccountId" is assumed as the parameter name you declared for method createupdateSAPAccount., like:
webservice static void createupdateSAPAccount(Id AccountId)
So if you have any other variable name over there is method specify it in the highlighted area.
All the merge fields should be in quotes, and for usage of sforce.apex.execute statement please refer to below link:
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_and_ajax.htm
If it anwers your question, please to vote this as Best Answer.
Hope it helps:
Thanks,
Balaji