You need to sign in to do that
Don't have an account?
Nelum Fernando
Unexpected token >
Hi,
I'm trying to excute the below javascript (without a real understanding of javascript) on a custom button within a Opportunity object. But it ends up with an error "Unexpected token >" Appreciate any help to sort this out. Thanks
{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")}
if('{!Quote.Status}'<>"Approved"){
alert("Quote needs to be approved ");
}
else{
window.open('/apex/echosign_dev1__AgreementTemplateProcess?masterid={!Opportunity.Id}&templateId=a0X2000000ARCFK');
}
I'm trying to excute the below javascript (without a real understanding of javascript) on a custom button within a Opportunity object. But it ends up with an error "Unexpected token >" Appreciate any help to sort this out. Thanks
{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")}
if('{!Quote.Status}'<>"Approved"){
alert("Quote needs to be approved ");
}
else{
window.open('/apex/echosign_dev1__AgreementTemplateProcess?masterid={!Opportunity.Id}&templateId=a0X2000000ARCFK');
}
Good to listen that its working for you.
The code which you put in the question is perfect if the Button is on Quote Object. But when you said that Button is on Opportunity Object, we cannot directly use "{!Quote.Status}" to get the Quotes's Status value. So, we need to retrieve the Opportunity's related Quote record to get the value of Status in that Quote record. Let us know if you have more questions.
Please mark a Best answer to close this thread so that it can be useful to others if required.
Best Regards,
BALAJI
All Answers
In Javascript, the comparison operator for 'Not Equals' should be used as '!=' instead of '<>'. Replacing the operator <> with != should work your code.
Please try below modified code. Let me know if that helps you.
Best Regards,
BALAJI
Thanks for the reply. It eliminated the unexpectd token error, but always generating the alert even if the quote is in approved status.
I just double checked in my Org and its working fine.
Can you please recheck the code and try sharing the screenshot. Also can you confirm the Type of the Button is Details Page Button.
Best Regards,
BALAJI
You mean to say that button is on Opportunity Object and when clicked, it should check it's related Quote's Status value and perform action accordingly. This can be done if Opportunity has One Quote only.
But I have a doubt, what if the opportunity has multiple quotes ? Which Quote's Status value should it check to perform action.
Please find below modified code which works fine if Opportunity has Single Quote. Let Me know if that works for you.
Best Regards,
BALAJI
It is working , we only do one quote per opportunity so this is perfect for us. Thank you very much for sedning this.
If it's not too much to ask can you please explain a bit about the code.
Thanks
Good to listen that its working for you.
The code which you put in the question is perfect if the Button is on Quote Object. But when you said that Button is on Opportunity Object, we cannot directly use "{!Quote.Status}" to get the Quotes's Status value. So, we need to retrieve the Opportunity's related Quote record to get the value of Status in that Quote record. Let us know if you have more questions.
Please mark a Best answer to close this thread so that it can be useful to others if required.
Best Regards,
BALAJI
Verywell explained, I understand it now. I appreciate your help vey much. THANK YOU.