Script Token Currency Default Value not showing | Community
Skip to main content
October 5, 2016
Solved

Script Token Currency Default Value not showing

  • October 5, 2016
  • 3 replies
  • 2507 views

1. We have a field called lead.Potential_Contribution_Margin__c that is populated with a number (eg: 12887062). This is actually currency. But it was pulling in as:

2. So to get it to add a $ and a comma and a decimal pt., through some online documentation I found this coding seemed to make that work as a Script Token ( which I called my.My Currency Token ): $number.currency($${lead.Potential_Contribution_Margin__c})

3. However, this broke the Default Value (if the lead.Potential_Contribution_Margin__c didn’t pull anything in. )

This worked when I didn’t have the Script token code:

But this is what it does now:

Anyone able to help me figure out how to get it coded to enter the Default Value if no number to pull in exists?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by

Great thank you! The only thing I couldn't do was get a different default value to pull in when I placed this in two different places, but I guess I can just make another token. This is what I ended up with in the Script Token:

#if ($lead.Potential_Contribution_Margin__c.toString().length() eq 0)

revenue lift

#else

$number.currency($${lead.Potential_Contribution_Margin__c})

#end

3 replies

Accepted solution
October 7, 2016

Great thank you! The only thing I couldn't do was get a different default value to pull in when I placed this in two different places, but I guess I can just make another token. This is what I ended up with in the Script Token:

#if ($lead.Potential_Contribution_Margin__c.toString().length() eq 0)

revenue lift

#else

$number.currency($${lead.Potential_Contribution_Margin__c})

#end

SanfordWhiteman
New Participant
October 7, 2016

Your Currency field is already a string in Velocity. You should just need $lead.Potential_Contribution_Margin__c.isEmpty().

Justin_Cooperm2
New Participant
October 5, 2016

Ok, that makes more sense. In your script, just have an #if statement to check if there is a value. If not, you can output your default...

Justin_Cooperm2
New Participant
October 5, 2016
Justin_Cooperm2
New Participant
October 5, 2016

Where are you seeing this:

You should never see that...

Justin

October 5, 2016

Oh - good call. When I send myself a test WITHOUT linking to a Lead:

When I put in a Lead that does not have any number in the Potential_Contribution_Margin_c field, it comes through as this (I want it to replace the token with the words revenue lift ):