Expand my Community achievements bar.

Join Adobe Journey Optimizer product experts for a live Ask Me Anything on October 15th at 8 AM PT about Expanding Your Mobile Reach with RCS & WhatsApp in AJO!

How to define multiple or nested if/elseif statements in AJO API triggered campaigns html templates

Avatar

Level 2

I'm Currently working on API Triggered campaign with in AJO and migrating Adobe V7 Realtime message center campaigns to AJO, I'm unable to replicate the below JavaScript logic from ACC to AJO 

Help me with any references or code snippets to transfer below ACC logic to AJO PQL Query logic

Specifically, to define multiple or nested if/else if statements in AJO API triggered campaigns html templates

JS LOGIC

<% var sections = rtEvent.ctx.eventinfo.sections;


//
for each (var section in sections){
if(section.sectionName.toString().toLowerCase() == 'service plan' && (section.bucketName.toString().toUpperCase() == 'A' || section.bucketName.toString().toUpperCase() == 'B' || section.bucketName.toString().toUpperCase() == 'C' || section.bucketName.toString().toUpperCase() == 'X'))
{
var osBucketName = section.bucketName.toString();
var osSectionName = section.sectionName.toString().toUpperCase();
}
if(section.sectionName.toString().toLowerCase() == 'connected plan' && (section.bucketName.toString().toUpperCase() == 'C0' || section.bucketName.toString().toUpperCase() == 'CX'))
{
var capBucketName = section.bucketName.toString();
var capSectionName = section.sectionName.toString().toUpperCase();
}
if(section.sectionName.toString().toLowerCase() == 'data Plan' && (section.bucketName.toString().toUpperCase() == '0' || section.bucketName.toString().toUpperCase() == '1' || section.bucketName.toString().toUpperCase() == '2' || section.bucketName.toString().toUpperCase() == '3' || section.bucketName.toString().toUpperCase() == '4' || section.bucketName.toString().toUpperCase() == '5' || section.bucketName.toString().toUpperCase() == 'X'))
{
var dpBucketName = section.bucketName.toString();
var dpSectionName = section.sectionName.toString().toUpperCase();
}
if(section.sectionName.toString().toLowerCase() == 'xm' && (section.bucketName.toString().toUpperCase() == '0' || section.bucketName.toString().toUpperCase() == '1' || section.bucketName.toString().toUpperCase() == '1A' || section.bucketName.toString().toUpperCase() == '3A' || section.bucketName.toString().toUpperCase() == '4A'))
{
var sxBucketName = section.bucketName.toString();
var sxSectionName = section.sectionName.toString().toUpperCase();
}
}%>

 

<% if(osBucketName == 'A'){var osStatus = "Inactive"; var osColor = "#916B00";
var osText = "We are unable to process your payment method. Please update today."; var osLink = rtEvent.ctx.notif_subccupdate.trim(); var osLinkText = "Update payment method";}
else if(osBucketName == 'B' || osBucketName == 'C'){var osStatus = "Active"; var osColor = "#007869";
var osText = rtEvent.ctx.eventinfo.plans.Plan.productId; var osLink = rtEvent.ctx.notif_view_modify.trim(); var osLinkText = "Manage Plans";}
else if(osBucketName == 'X') {var osLink = rtEvent.ctx.notif_view_modify.trim(); var osLinkText = "Click here to view, renew or modify your service plan";}

if(osBucketName != 'X'){%>
<tr>
<td align="left" style="font-family:'CircularXX', Arial, sans-serif; -webkit-text-size-adjust:none; mso-ansi-font-weight:bold; font-size: 14px; font-weight:500; line-height: 17px; text-align:left; color:<%= osColor %>; padding-bottom: 8px;">
<%= osStatus %>
</td>
</tr><%}%>

 

"context": {
"eventinfo": {
"sections": [
{
"sectionName": "Pressure",
"bucketName": "TPM_4",
"status": "GREEN"
},
{
"sectionName": "Maintenance",
"bucketName": "SM_6",
"status": "GREEN"
},
{
"sectionName": "Recall",
"bucketName": "RC_X",
"status": ""
},
{
"sectionName": "Information",
"bucketName": "DLR_3",
"status": ""
},
{
"sectionName": "Service Plan",
"bucketName": "C",
"status": "GREEN"
},
{
"sectionName": "Connected Plan",
"bucketName": "C",
"status": "GREEN"
},
{
"sectionName": "SiriusXM",
"bucketName": "0",
"status": ""
},
{
"sectionName": "Data Plan",
"bucketName": "0",
"status": ""
}
],

1 Reply

Avatar

Employee Advisor