Read more than one values from Variable in Filtering condtions

Avatar

Avatar
Validate 1
Level 1
mustufam5967803
Level 1

Likes

2 likes

Total Posts

15 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
mustufam5967803
Level 1

Likes

2 likes

Total Posts

15 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
mustufam5967803
Level 1

05-03-2020

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);

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Contributor
MVP
Milan_Vucetic
MVP

Likes

166 likes

Total Posts

384 posts

Correct reply

135 solutions
Top badges earned
Contributor
Springboard
Shape 1
Validate 25
Validate 10
View profile

Avatar
Contributor
MVP
Milan_Vucetic
MVP

Likes

166 likes

Total Posts

384 posts

Correct reply

135 solutions
Top badges earned
Contributor
Springboard
Shape 1
Validate 25
Validate 10
View profile
Milan_Vucetic
MVP

05-03-2020

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

 

Answers (0)