SOLVED

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

Go to solution
Jeroen_Krah
Level 2

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

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?

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

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

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 "@".

View solution in original post

5 REPLIES 5
SanfordWhiteman
Level 10 - Community Moderator

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

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 "@".
Jeroen_Krah
Level 2

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

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

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

@Jeroen_Krah ,

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

SanfordWhiteman
Level 10 - Community Moderator

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

Indeed, and FlowBoost has a proper parsing function built in (you can also use a regex of course):

emailParts = FBUtil.string.partsFromEmail({{lead.Email Address}});
emailDomain = emailParts.domain;

 

Jeroen_Krah
Level 2

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

Thanks Jo, I use indeed Flowboost for exact this issue (and more).