Hi Team ,
We have a field at opportunity level which is a custom field and we want to display that value in the body of the email , when we use velocity script in the email script token with that value it gives us 35000.0 , but we would like to display as 35,000 . Can you help me how this can be fixed ?
Solved! Go to Solution.
Just noticed one thing if i add a token in the body ${{my.formattedAmount}} like this it gives an error but if i give $ {{my.formattedAmount}} then it works not sure if thats the issue ?
Of course. If you use the prefix ${
that conflicts with Marketo’s email variable syntax.
Do don’t put the dollar sign outside the Velocity token. Add it to the format string (since in fact, it is part of the format!)
${number.format("${esc.d}${esc.h}${esc.h},${esc.h}${esc.h}${esc.h}",$yourField)}
Not providing your (attempted) code, nor even the datatype of this field, makes it harder to provide useful help!
If the field is a Float, Currency, or Integer, you want
${number.format("${esc.h}${esc.h},${esc.h}${esc.h}${esc.h}",$yourField)}
but impossible to say for sure.
Please remember to provide more technical details in community threads.
I apologize for not providing more details in this thread.
The field type is set to currency.
Yesterday, I tested some code based on suggestions from ChatGPT, but I am unable to locate those details to share with you at the moment.
I also tested the code you provided, which indicated it might be compatible with the currency data type. When I included the email script token (adding the code you shared in the script) in the subject line, it returned the correct value in the proper format, for example: 35,000.
But i want to use it in the body of the email at different places and when i add that token in the code of the HTML it gives me variable not defined error
Additionally, I would like to include the dollar sign with the amount in the body of the email, so it should appear as $35,000.
Could you please assist me in finding a solution for this?
Lastly, while I was adding the token, I encountered an error stating that the images do not have a mktoname. This was unexpected, as we are hosting them on our company server. I'm unsure if this error is related to the use of the token.
Apologies once again for not sharing the entire details
Looking forward to your response
Regards,
Akshat
Just noticed one thing if i add a token in the body ${{my.formattedAmount}} like this it gives an error but if i give $ {{my.formattedAmount}} then it works not sure if thats the issue ?
Additionally when i preview this is how it displays with the tokens and it make the width longer , i guess it will work as expected when we render with a actual lead which has a value against it right ?
I just tried using the below and it gives me the result , let me know if something looks unappropriate to you
Token used :
This is the code : $${number.format("${esc.h}${esc.h},${esc.h}${esc.h}${esc.h}", $OpportunityList.get(0).new_approvedworkingcapitaltotalamount)}
Just added a extra $ before the toke you shared
Just noticed one thing if i add a token in the body ${{my.formattedAmount}} like this it gives an error but if i give $ {{my.formattedAmount}} then it works not sure if thats the issue ?
Of course. If you use the prefix ${
that conflicts with Marketo’s email variable syntax.
Do don’t put the dollar sign outside the Velocity token. Add it to the format string (since in fact, it is part of the format!)
${number.format("${esc.d}${esc.h}${esc.h},${esc.h}${esc.h}${esc.h}",$yourField)}
Yesterday, I tested some code based on suggestions from ChatGPT, but I am unable to locate those details to share with you at the moment.
There’s a 0% chance that ChatGPT will give you usable code for Marketo’s Velocity environment. Don’t use it.
Lastly, while I was adding the token, I encountered an error stating that the images do not have a mktoname. This was unexpected, as we are hosting them on our company server. I'm unsure if this error is related to the use of the token.
This cannot be related to the use of Velocity {{my.tokens]} for formatting. You might want to open a new thread about it.
Thanks @SanfordWhiteman This helps
Let me try the new code you shared and test it out
Thankyou so much for your help once again
Have a nice weekend ahead !!
Regards,
Akshat