Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Driving conditional content in the absence of a field

Avatar

Avatar
Level 1
michaelh7762985
Level 1

Likes

0 likes

Total Posts

1 post

Correct Reply

0 solutions
View profile

Avatar
Level 1
michaelh7762985
Level 1

Likes

0 likes

Total Posts

1 post

Correct Reply

0 solutions
View profile
michaelh7762985
Level 1

08-12-2019

Hi everyone,

I'm currently working with a transactional eDM using SOAP UI for testing. This particular eDM has three pieces of content which are supposed to render under certain circumstances.

The fields which are driving this, however, only have one value and if this value is not passed via the API, then the fields aren't passed at all.

What I've been attempting to do is write conditional statements to drive the content of the email by checking if the field is present. eg.

<% if (rtEvent.ctx.FIELDNAME1 == undefined || rtEvent.ctx.FIELDNAME2 == undefined || rtEvent.ctx.FIELDNAME3 == undefined) { %>

CONTENT 

I was testing this by removing the particular fields from the SOAP event to see if this simulated the field not being passed, however I'm unsure if this is the correct thing to do or not.

Using 'undefined' doesn't appear to work. I have tried 'null' as well.

Does anyone know whether what I'm attempting is possible? Is this the correct way / syntax to check for the absence of a field?

Thanks!

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 1
MVP
_Manoj_Kumar
MVP

Likes

104 likes

Total Posts

301 posts

Correct Reply

97 solutions
Top badges earned
Validate 1
Contributor
Ignite 1
Shape 1
Give Back 5
View profile

Avatar
Validate 1
MVP
_Manoj_Kumar
MVP

Likes

104 likes

Total Posts

301 posts

Correct Reply

97 solutions
Top badges earned
Validate 1
Contributor
Ignite 1
Shape 1
Give Back 5
View profile
_Manoj_Kumar
MVP

16-12-2019

Hello Michael,
Try this

if (typeof rtEvent.ctx.FIELDNAME1  === "undefined"){

CONTENT HERE

}

 

OR

if(rtEvent.ctx.FIELDNAME1){

CONTENT HERE

}

 

Let me know if that helps.

 

Answers (0)