SOLVED

Script Token Currency Default Value not showing

Go to solution
Anonymous
Not applicable

Script Token Currency Default Value not showing

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:

1.jpg

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})

2.jpg

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: 3.jpg

But this is what it does now:4.jpg

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

1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous
Not applicable

Re: Script Token Currency Default Value not showing

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

View solution in original post

6 REPLIES 6
Justin_Cooperm2
Level 10

Re: Script Token Currency Default Value not showing

Where are you seeing this:

4.jpg

You should never see that...

Justin

Anonymous
Not applicable

Re: Script Token Currency Default Value not showing

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

6.jpg

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 😞

5.jpg

Justin_Cooperm2
Level 10

Re: Script Token Currency Default Value not showing

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
Level 10

Re: Script Token Currency Default Value not showing

Anonymous
Not applicable

Re: Script Token Currency Default Value not showing

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
Level 10 - Community Moderator

Re: Script Token Currency Default Value not showing

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