Avatar

Correct answer by
Community Advisor

Hi,

You can use Javascript JXON then, it's easier. Consider the following workflow:

20190627-104703-screenshot-1.jpg

Activity 1:

var query = {queryDef: {

  schema: "temp:enrich32",

  operation: "select",

  select:{ node: [

    {expr: "@firstName"}

  ]},

  where:{}

}};

vars.query = JSON.stringify(query); // string

Activity 2:

var query = JSON.parse(vars.query); // json

var condition = {

  boolOperator: 'AND',

  condition:[

    {boolOperator: 'OR', internalId: "0", expr: "@gender = 'M'"},

    {boolOperator: "OR", internalId: "1", expr: "@gender = 'F'"},

  ],

};

query.queryDef.where.condition = condition; // add condition to the query

You may use directly query as a JXON (see Using XML ) or convert it with "DOMDocument.fromJXON(query).toXMLString()" which outputs:

<?xml version='1.0'?>

<queryDef operation="select" schema="temp:enrich32">

     <select>

          <node expr="@firstName"/>

     </select>

     <where>

          <condition boolOperator="AND">

               <condition boolOperator="OR" expr="@gender = 'M'" internalId="0"/>

               <condition boolOperator="OR" expr="@gender = 'F'" internalId="1"/>

          </condition>

     </where>

</queryDef>

Regards

View solution in original post