Script token inserts code with change data value flow step in stead of the resultant | Community
Skip to main content
Level 2
October 16, 2024
Solved

Script token inserts code with change data value flow step in stead of the resultant

  • October 16, 2024
  • 1 reply
  • 1997 views

Hi all,

I have a script token {{my.getdomain}} that splits an email address and retrieves the domain name in a variable:

#set( $em = ${lead.Email} ) #set( $dom = $em.split("@") ) $!{dom[1]}

 

However, with the 'add data value' flow step it adds into the field (string) webdomain:

{"codeBlock":"#set( $em = ${lead.Email} )\n#set( $dom = $em.split(\"@\") )\n$!{dom[1]}","scriptingObjects":{"standard":{"2":{"label":"Person","fields":{"31":{"label":"Email Address"}}}}}}

 

in stead of the domain name from the email address (I did check the field 'email address' on the right hand pane).

If I add the same token in an email, it renders correctly.

Any ideas why the domain name is not entered into the field?

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 SanfordWhiteman
Email Script Tokens (a.k.a. Velocity tokens) only execute when embedded in emails. In all other contexts they are simply treated as text.

I should also note your code is not correct for finding the domain part of a syntactically valid email. The domain part is the last item after splitting on "@", not the second item. Emails can have more than one "@".

1 reply

SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
October 16, 2024
Email Script Tokens (a.k.a. Velocity tokens) only execute when embedded in emails. In all other contexts they are simply treated as text.

I should also note your code is not correct for finding the domain part of a syntactically valid email. The domain part is the last item after splitting on "@", not the second item. Emails can have more than one "@".
JeroenKrAuthor
Level 2
October 16, 2024

ok, thanks for your reply. 

That is a pity as I would rather not use a webhook service when such a powerful tool as Velocity is available.

Jo_Pitts1
Community Advisor
Community Advisor
October 16, 2024

@jeroenkr ,

Velocity is super powerful, but it only exists in the context of emails.  However, Velocity can't write values back to the database.. something you typically want to do.

 

If you need a webhook service, I recommend FlowBoost. It's ideal for using in Marketo as it was built for it from the ground up.

 

Cheers

Jo