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?
Solved! Go to Solution.
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
Where are you seeing this:
You should never see that...
Justin
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 😞
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...
check out our examples here http://developers.marketo.com/email-scripting/
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
Your Currency field is already a string in Velocity. You should just need $lead.Potential_Contribution_Margin__c.isEmpty().