1

In our organisation we are using zuora for creating quotes & subscriptions.

In opportunity page we had a custom button to create quotes but it's normally routing to custom VF page.

But whenever a user tries to create any quote, the shipping address should not be null. If shipping address = null, then it needs to throw error to user.

So, I created this custom button:

{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/24.0/apex.js")} 

if(ISBLANK({!Opportunity.Shipping_City__c})){ 
alert("Shipping address should not be null") 
} 
else { 
window.open('https://zqu.cs5.visual.force.com/apex/CreateQuote?oppId={!Opportunity.Id}&quoteType=Subscription&scontrolCaching=1&stepNumber=1');

} 

Error is coming like

A problem with the OnClick JavaScript for this button or link was encountered:

ISBLANK is not defined

Why am I getting this error?

3

You can only use ISBLANK and other merge functions inside a merge field ({!...}).

Incorrect

if(ISBLANK({!Opportunity.Shipping_City__c})){ 

Correct

if({!ISBLANK(Opportunity.Shipping_City__c)}){ 
1

JavaScript doesn't understand ISBLANK. Try something like this:

if('{!Opportunity.Shipping_City__c}') {
  alert("Shipping address should not be null") 
} 
else { 
  window.open('https://zqu.cs5.visual.force.com/apex/CreateQuote?oppId={!Opportunity.Id}&quoteType=Subscription&scontrolCaching=1&stepNumber=1');

} 
  • 1
    Wouldn't you want quotes around that merge expression? – martin Mar 23 '17 at 14:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.