Read more than one values from Variable in Filtering condtions | Community
Skip to main content
Level 3
March 5, 2020
Solved

Read more than one values from Variable in Filtering condtions

  • March 5, 2020
  • 1 reply
  • 7217 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Milan_Vucetic

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

 

1 reply

Milan_Vucetic
Milan_VuceticAccepted solution
Level 9
March 5, 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

 

Milan_Vucetic
Level 9
March 6, 2020

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