SOLVED

Email Module hide based on custom objects

Go to solution
Highlighted
Level 3

Email Module hide based on custom objects

In email template, module has been created and want to hide the email module when custom objects list is empty or not exists. For example- lead A is linked with custom objects list product so here in email I want to show email module but for lead B is not linked custom objects list product so here I want to hide the email module for lead B only. Can this be done using velocity script?

Email Module name is- recommend item

Custom objects is - Product

Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Level 6 - Champion

Re: Email Module hide based on custom objects

Absolutely you can do this. Basically, you create a script token that looks for whatever value in whatever field you need, then the 'true' output for that query is a block of HTML that is whatever you want to show, and the 'false' output is nothing. Here's a really basic example that's not querying a custom object, but it's the same exact principal. Just pull your field from the right-side integration pane when you create your token and drop in your HTML as the output. 

 

##Content section method, this will show each section where that has been selected as True, and will skip the others. Note, sometimes an extra line breaks can appear between sections when using this method. 
{{Content Token A}}
#if (${lead.fieldA} == "1")
	<table>
		<tr>
			<td>Headline</td>
		</tr>
		<tr>
			<td>Drop your full html content block here with inline CSS.</td>
		</tr>
		<tr>
			<td><a href="#" target="_blank">CTA</a></td>
		</tr>
	</table> 
#end

View solution in original post

2 REPLIES 2
Highlighted
Level 6 - Champion

Re: Email Module hide based on custom objects

Absolutely you can do this. Basically, you create a script token that looks for whatever value in whatever field you need, then the 'true' output for that query is a block of HTML that is whatever you want to show, and the 'false' output is nothing. Here's a really basic example that's not querying a custom object, but it's the same exact principal. Just pull your field from the right-side integration pane when you create your token and drop in your HTML as the output. 

 

##Content section method, this will show each section where that has been selected as True, and will skip the others. Note, sometimes an extra line breaks can appear between sections when using this method. 
{{Content Token A}}
#if (${lead.fieldA} == "1")
	<table>
		<tr>
			<td>Headline</td>
		</tr>
		<tr>
			<td>Drop your full html content block here with inline CSS.</td>
		</tr>
		<tr>
			<td><a href="#" target="_blank">CTA</a></td>
		</tr>
	</table> 
#end

View solution in original post

Highlighted
Level 10 - Community Moderator

Re: Email Module hide based on custom objects

Except

 

#if (${lead.fieldA} == "1")

 

 

should be 

 

#if( $lead.fieldA.equals("1") )

 

 

double-equals is buggy in Velocity and should be avoided.  Also curly braces aren't necessary in #directives.