Hello,
I'm trying to change the value of a field coming from an integration and appended via Custom Object and I wanted to turn it into a date field, as I would need to use the on or before/on or after criteria - but it's currently with the following format: YEAR/DAY_MONTH (example: 2023/01_08).
To do so, I thought to create a triggered smart campaign with a data change flow step that would call a velocity script token to change the format to ISO, and then add it to a custom field. The issue I'm encountering is that the custom field, to have a tokenized value, needs to be a string, so the script gets added as a value rather than a date format.
This is the script I'm currently using:
#set( $myDate = "${testCO_cList.get(0).entry_Term_ID}" ) ## Replace this with your actual date variable
#if( $myDate && $myDate.length() > 0 )
#set( $parts = $myDate.split("/") )
#set( $year = $parts[0] )
#set( $dayMonth = $parts[1] )
#if( $dayMonth.contains("_") )
#set( $dayMonthParts = $dayMonth.split("_") )
#set( $day = $dayMonthParts[0] )
#set( $month = $dayMonthParts[1] )
#set( $isoDate = "${year}-${month}-${day}T00:00:00.000Z" )
ISO Date: $isoDate
#else
Invalid Day/Month Format
#end
#elseNo Date Available
#end
Not sure this is the correct way to go about it, any suggestions are welcome 🙂
Thanks,
Livia
Solved! Go to Solution.
Hello Livia,
you can't use Velocity to update a field. It's called "Email Script Token" as it can only render its output on emails.
For your case, I think you will have to use an outside service. Send your field through a webhook to - e.g. - https://flowboo.st/ and have it transformed there, then write it back via the response.
Hello Livia,
you can't use Velocity to update a field. It's called "Email Script Token" as it can only render its output on emails.
For your case, I think you will have to use an outside service. Send your field through a webhook to - e.g. - https://flowboo.st/ and have it transformed there, then write it back via the response.
Ok thanks, another solution was to change the format before it entered Marketo. I will take a look at the webhook, thanks for your help 🙂
Quite so, in FlowBoost (and in Velocity too, if it worked in this context!) you can parse non-standard dates by providing a pattern, no need for any manual splitting:
isoDate = FBUtil.time("2023/12_08", "YYYY'/'MM'_'DD");