Good afternoon, everyone. I'm currently working on uploading an encrypted email file into Adobe Campaign using the Read List activity.
Subsequent to this step, I have a JavaScript activity in which I've implemented the following code:
function decryptValue(encryptedValue) {
var decryptedValue = '';
for (var i = 0; i < encryptedValue.length; i++) {
var encryptedCharCode = encryptedValue.charCodeAt(i);
var decryptedCharCode = encryptedCharCode - 1;
decryptedValue += String.fromCharCode(decryptedCharCode);
}
return decryptedValue;
}
var query = xtk.queryDef.create(
'<queryDef schema="temp:readGroup" operation="select">' +
'<select>' +
'<node expr="email"/>' +
'</select>' +
'</queryDef>'
);
var records = query.ExecuteQuery();
for (var i = 0; i < records.length; i++) {
var decryptedEmail = decryptValue(records[i].email);
instance.vars.email = decryptedEmail;
logInfo("Decrypted Email is: " + instance.vars.email);
}
After this code, I will need to update that list with an List Update activity, but I am getting this message error while executing the JavaScript activity:
And my workflow loos like this:
I would greatly appreciate any assistance in resolving these issues.
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @renanbarhbosa ,
In node expr, try giving "@email" instead of "email"
<node expr="@email"/>
Views
Replies
Total Likes
Views
Replies
Total Likes
Hello, Sarathy. Thanks for the advice, I was able to proceed with the code structure and I got new errors along the process.
This is my code right now:
And I'm getting those messages:
I need to know why I can't access the 11 elements within my list.
Best regards,
Renan.
Views
Replies
Total Likes
@renanbarhbosa , copy paste the below script and check display logs.
You can able to see email address in it.
var data = xtk.queryDef.create(
<queryDef schema={vars.targetSchema} operation="select" >
<select>
<node expr= "@email" />
</select>
</queryDef>
)
var output = data.ExecuteQuery();
for each (var result in output)
{
vars.emailAddress = result.@email;
logInfo("Email: "+vars.emailAddress);
}
Views
Replies
Total Likes
The variable result which you are using in line 14 isn't defined, hence it is throwing the undefined error.
Could you please try using the below code.
var schemaName = vars.targetSchema.substring(vars.targetSchema.indexOf(":") + 1);
var collection = < {schemaName + '-collection'} xtkschema = { vars.targetSchema} _operation = "update" _key = "@email" / >
var query = xtk.queryDef.create(
<queryDef schema={vars.targetSchema} operation="select" lineCount="1">
<select >
<node expr="@email" />
</select>
</queryDef>
);
logInfo("schemaName: " + schemaName);
logInfo("collection: " + collection);
logInfo("query: " + query);
//var res = result[schemaName];
//logInfo("emailll: " + res.email); // why the emails aren't showing in Campaign log? Why those strings can't be captured in "result[schemaName]"?
var res = query.ExecuteQuery();
for Each(var e in res)
{
logInfo("Email: "+e.@email)
var updatedEmail = '';
// return emails that was written and captured in the page.
for (var j = 0; j < e.@email.length; j++) {
var charCode = e.@email.charCodeAt(j);
updatedEmail += String.fromCharCode(charCode 1);
logInfo("email " + updatedEmail);
}
}
Views
Replies
Total Likes