Expand my Community achievements bar.

Use enumeration label instead of value in email delivery

Avatar

Level 7

Hello, I'm trying to use the enumeration label in a delivery instead of the internal value in an email delivery. I would like to know how to do it.

Heku__0-1730105963527.png

I've already tried with exportFormat/analyze="true", but I think it only works for deliveries that generate a file.

Heku__1-1730106034113.png

How should I do this for the email delivery?

Thank you in advance.

 

 

5 Replies

Avatar

Level 7

Hi @Heku_,

 

I share with you some useful documentation links that can help you to solve your issue:

Managing enumerations 

Comfiguring export jobs 

JavaScript scripts and templates 

 

Some solutions that come to my mind, that you can try are:

 

-Create a custom function inside a JavaScript Activity, before the delivery to transform the enumeration value into it's label. Store the label in a temporary field in order to use it in the delivery.

-Create a content block where you use JavaScript  to retreive and display the enumeration. I share with you a possible solution as a guidance.

 

<%=NLWS.nmsEnum.getLabel("EnumSchema", fieldtouse) %>
*Inside EnumSchema, insert the schema name for the enumeration
*Inside field to use put the field you want to use

 

Regards,

Celia

Avatar

Level 7

Hello, where did you get this from? 

<%=NLWS.nmsEnum.getLabel("EnumSchema", fieldtouse) %>

 I've tried to use it like this, but the message does not even arrive.

Heku__0-1730390171587.png

When i try to use it in a js activity NLWS.nmsEnum it says that this function does not exist. I have AC v7

Avatar

Level 7

Hi @Heku_,

 

Sorry that was a mistake by my side, the NLWS is supported in Adobe Campaign Standard. 

 

You can try to use queryDef to retrieve the label for a specific enumeration value that comes from the xtk: enumValue schema.

 

A solution as a guidance:

var enumSchema = "EnumSchema"; 
var enumValue = "fieldtouse";  

var queryDef = `<queryDef schema="xtk:enumValue">
                   <select>
                      <node expr="@label" alias="label"/>
                   </select>
                   <where>
                      <condition expr="@name='${enumSchema}'"/>
                      <condition expr="@value='${enumValue}'"/>
                   </where>
                </queryDef>`;

try {
   var query = xtk.queryDef.create(queryDef);
   var result = query.ExecuteQuery();

   if (result.length > 0) {
      var label = result[0].label;
      logInfo("Label: " + label);
   } else {
      logError("No label found.");
   }
} catch (e) {
   logError("Error: " + e.message);
}

** Replace "EnumSchema" with your enum schema name
** Replace "fieldtouse" with the enum value you need

 

 

Finally I leave you with some documentation links:

Adobe API JS 

 queryDef 

Regards, 

Celia

Avatar

Level 7

Hello @ccg1706, thank you for your reply,

That is a good solution, but how do I use this label in the delivery?

 

Regards,

Héctor

Avatar

Level 7

Hi @Heku_

 

Once you have retrieved the label you can store it and use it in the delivery by creating a dynamic variable or a custom attribute.

 

For example:

<html>
  <body>
    <p>Dear customer,</p>
    <p>Your choice  is: {{label}}</p>
  </body>
</html>

Hope it helps!

 

Regards, 

Celia