You need to sign in to do that
Don't have an account?
Java Script Error
Hi,
I have a custom button which has "Onclick" execute java script.
I am looking at the status of a field and then redirecting the user appropriately.
But i am encountering an error, which i am unable to figure out.
if({!Opportunity.StageName}=='Prospecting')
{
alert('You cannot perform action');
}
else
{
window.location.href="https://www.appextremes.com/apps/Conga/PointMerge.aspx?sessionId={!API.Session_ID}&serverUrl={!API.Partner_Server_URL_80}&id={!Opportunity.Id}&reportid=00O600000023k2f?pv0={!Opportunity.Id}&reportid=00O600000023k2k?pv0={!Contact.Id}&reportid=00O600000023k3O?pv0={!Opportunity.Id}&reportid=00O600000023k3T?pv0={!Opportunity.Id}&reportid=00O600000023qu9?pv0={!Opportunity.Id}&ESVisible=1&ESAgreementName={!Opportunity.Name}&ESSignatureType=2&TemplateId={!IF ( Opportunity.RecordTypeId = "012600000005Eso", IF ( ISPICKVAL ( Opportunity.Payment_Methond__c , "Credit Card" ) , "a0G60000004z7sv" , "a0G60000004z7t0" ) , IF ( ISPICKVAL ( Opportunity.Payment_Methond__c , "Credit Card" ) , "a0G60000003Zej9" , "a0G60000003ZejE" ) )}&ds4={!IF( $Profile.Name = "System Administrator", "0", "1")}&ds7={!IF( $Profile.Name = "System Administrator", "0", "4")}";
}
The error is:
A problem with the OnClick JavaScript for this button or link was encountered:
missing ) after condition.
It seems to me correct. i do not know what i am missing. can anyone help me here?
Thanks,
Sales4ce
.
Use window.open( "https://www.appextremes.com/apps/Conga/PointMerge.aspx?sessionId={!API.Session_ID}&serverUrl={!API.Partner_Server_URL_80}&id={!Opportunity.Id}&reportid=00O600000023k2f?pv0={!Opportunity.Id}&reportid=00O600000023k2k?pv0={!Contact.Id}&reportid=00O600000023k3O?pv0={!Opportunity.Id}&reportid=00O600000023k3T?pv0={!Opportunity.Id}&reportid=00O600000023qu9?pv0={!Opportunity.Id}&ESVisible=1&ESAgreementName={!Opportunity.Name}&ESSignatureType=2&TemplateId={!IF ( Opportunity.RecordTypeId = "012600000005Eso", IF ( ISPICKVAL ( Opportunity.Payment_Methond__c , "Credit Card" ) , "a0G60000004z7sv" , "a0G60000004z7t0" ) , IF ( ISPICKVAL ( Opportunity.Payment_Methond__c , "Credit Card" ) , "a0G60000003Zej9" , "a0G60000003ZejE" ) )}&ds4={!IF( $Profile.Name = "System Administrator", "0", "1")}&ds7={!IF( $Profile.Name = "System Administrator", "0", "4")} ");
Let me know if you face any issues.
All Answers
Hi,
I think you need to enclose {!Opportunity.StageName} with single quotes in 'IF" condition.
Just add single quotes and it should resolve the issue.
Replace if({!Opportunity.StageName}=='Prospecting') with if( '{!Opportunity.StageName}' == 'Prospecting')
That definitely helped me sole one problem, but it created a new problem.
In the else part i am trying to navigate the user to a different URL.
How can i open it in a new window.
window.location.href= "https://www.appextremes.com/apps/Conga/PointMerge.aspx?sessionId={!API.Session_ID}&serverUrl={!API.Partner_Server_URL_80}&id={!Opportunity.Id}&reportid=00O600000023k2f?pv0={!Opportunity.Id}&reportid=00O600000023k2k?pv0={!Contact.Id}&reportid=00O600000023k3O?pv0={!Opportunity.Id}&reportid=00O600000023k3T?pv0={!Opportunity.Id}&reportid=00O600000023qu9?pv0={!Opportunity.Id}&ESVisible=1&ESAgreementName={!Opportunity.Name}&ESSignatureType=2&TemplateId={!IF ( Opportunity.RecordTypeId = "012600000005Eso", IF ( ISPICKVAL ( Opportunity.Payment_Methond__c , "Credit Card" ) , "a0G60000004z7sv" , "a0G60000004z7t0" ) , IF ( ISPICKVAL ( Opportunity.Payment_Methond__c , "Credit Card" ) , "a0G60000003Zej9" , "a0G60000003ZejE" ) )}&ds4={!IF( $Profile.Name = "System Administrator", "0", "1")}&ds7={!IF( $Profile.Name = "System Administrator", "0", "4")} " ;
Its raising another error:
A problem with the OnClick JavaScript for this button or link was encountered:
unterminated string literal
Any Idea/pointers?
Thanks,
Sales4ce
Use window.open( "https://www.appextremes.com/apps/Conga/PointMerge.aspx?sessionId={!API.Session_ID}&serverUrl={!API.Partner_Server_URL_80}&id={!Opportunity.Id}&reportid=00O600000023k2f?pv0={!Opportunity.Id}&reportid=00O600000023k2k?pv0={!Contact.Id}&reportid=00O600000023k3O?pv0={!Opportunity.Id}&reportid=00O600000023k3T?pv0={!Opportunity.Id}&reportid=00O600000023qu9?pv0={!Opportunity.Id}&ESVisible=1&ESAgreementName={!Opportunity.Name}&ESSignatureType=2&TemplateId={!IF ( Opportunity.RecordTypeId = "012600000005Eso", IF ( ISPICKVAL ( Opportunity.Payment_Methond__c , "Credit Card" ) , "a0G60000004z7sv" , "a0G60000004z7t0" ) , IF ( ISPICKVAL ( Opportunity.Payment_Methond__c , "Credit Card" ) , "a0G60000003Zej9" , "a0G60000003ZejE" ) )}&ds4={!IF( $Profile.Name = "System Administrator", "0", "1")}&ds7={!IF( $Profile.Name = "System Administrator", "0", "4")} ");
Let me know if you face any issues.
Thanks Imran! It worked for me.
Sales4ce