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

SOLVED

Read more than one values from Variable in Filtering condtions

mustufam5967803
Level 2
Level 2

I am trying to pass multiple values from a variable in JavaScript activity into filter condition next activity, however constantly getting an error saying 'res.getElementsByTagName is not a function'.

Can anyone please have a look and help with their valuable input.

The code I am using is:


var winner = xtk.queryDef.create(<queryDef schema="nms:delivery" operation="select">
<select>
<node expr="@id"/>
<node expr="@internalName"/>
<node expr="@state"/>
<node expr="@created"/>
</select>
<where>

<condition expr={("@state = '95' ")}/>

</where>
<orderBy>
<node expr="[@created]" sortDesc="true" />
</orderBy>
</queryDef>);

res = winner.ExecuteQuery();

var resultArray = new Array();

var result= res.getElementsByTagName("nms:delivery");

for each (var row in result)
{
resultArray.push("'"+row.getAttribute("@internalName")+"'");
//resultArray.push("'"+row.@internalName+"'");

}

vars.finalResult = resultArray.join(",").slice(1,2,3,4,5);

logInfo("The Internal Names are" + vars.finalResult);

Adobe Campaign Adobe Campaign Classic
1 Accepted Solution
Milan_Vucetic
Correct answer by
Community Advisor
Community Advisor

Hi @mustufam5967803 ,

 

why do not you iterate res variable immediately and use values?

 

for each (var row in res)
{
resultArray.push(row.@internalName);

}

 

Generally, you must convert output to the DOM object first in order to avoid error if I am not wrong:

res = winner.ExecuteQuery();

res = DOMDocument.fromXMLString(res);

and then to use

var result= res.getElementsByTagName("nms:delivery");

 

Regards,

Milan

 

View solution in original post

5 Replies
Milan_Vucetic
Correct answer by
Community Advisor
Community Advisor

Hi @mustufam5967803 ,

 

why do not you iterate res variable immediately and use values?

 

for each (var row in res)
{
resultArray.push(row.@internalName);

}

 

Generally, you must convert output to the DOM object first in order to avoid error if I am not wrong:

res = winner.ExecuteQuery();

res = DOMDocument.fromXMLString(res);

and then to use

var result= res.getElementsByTagName("nms:delivery");

 

Regards,

Milan

 

View solution in original post

mustufam5967803
Level 2
Level 2

Hi milanv69354962,

Thank you for your prmopt response, it worked :). 
One more quick help needed, I want select top 5 records however it is taking them all.
Also, I want to pass the values into split activity and "is Included in" but getting an error. The variable I am passing here is  $(vars/@finalResult).

Milan_Vucetic
Community Advisor
Community Advisor

Hi @mustufam5967803,

 

try to add parameter line Count to your query and field for sorting by.

 
 
 
 
 
 

js.PNG

 

This should work for you.

Regarding reading variable in split please check: https://helpx.adobe.com/uk/campaign/kb/instance-variable-in-workflow.html

 

Regards,

Milan

mustufam5967803
Level 2
Level 2

Thanks @Milan_Vucetic 

One last help, when i am paasing data into variable in split acitvity it is giving an error saying unable to parse the expression.

 

Milan_Vucetic
Community Advisor
Community Advisor

Hi @mustufam5967803

 

I do not have enough information to help you about mentioned.

You can use JS instead of Split node and create several branches.

Example code (change it per your needs):

 

var test= 1;
if(test> 1){
task.postEvent(task.transitionByName("branch1"));

} else {
task.postEvent(task.transitionByName("branch2"));
};

 

Regards,

Milan