Using Velocity Script for Multiple Values in Multiple fields

Techgrad
Level 1

Using Velocity Script for Multiple Values in Multiple fields

This is my first time using Velocity so apologies if it's an obvious answer. We need to populate articles based on values from 3 fields ex below

 

Industry can have 2 or more
Function may be multiple
Role also multiple

 

For example if lead has Industry as heavy machinery role CXO and function purchasing or Operations should display Article 1
Mean while if another lead has Industry as heavy machinery role SVP and function purchasing or Finance should display Article 1

 

Is this possible by velocity script?

Tags (1)
1 REPLY 1
Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: Using Velocity Script for Multiple Values in Multiple fields

This is possible using the if-else  construct available within the velocity, below the sample script to do the personalization as you have articulated in the example in question. assuming "Industry", "Role", and "Function" are the field names

 


For example if lead has Industry as heavy machinery role CXO and function purchasing or Operations should display Article 1
Mean while if another lead has Industry as heavy machinery role SVP and function purchasing or Finance should display Article 1

 

#if($lead.Industry.equals("Heavy Machinery") && (($lead.Role.equals("CXO") && ($lead.Function.equals("Purchasing") || $lead.Function.equals("Operations"))) || ($lead.Role.equals("SVP") && ($lead.Function.equals("Finance")) || ($lead.Function.equals("Purchasing")))))
Article 1
##add multiple elseifs to account for all the possible conditional statements
#elseif (  ) #add the apt condition in elseif construct
Article 2
#else
##display catch-all content for people not qualifying for any of the conditions above

 

If you provide us the exact conditions along with the respective article options for each, we can help you with the script.

And, you need to select the apt. field in the tree in the RHS of the email script editor for the velocity to be able to access the data within those fields in the script, needless to say all the names you use in the script must match with the actual field names you have in your instance.