Using variable inside <where> condition

Avatar

Avatar

marcinkacz

Avatar

marcinkacz

marcinkacz

02-08-2017

Hi,

I'm hoping that you can help me again. My question is: how I can insert variable intName instead of 'OP125' inside <where> condition?

My code in JS workflow activity is:

var intName = 'OP125'

var query = xtk.queryDef.create( 

  <queryDef schema="xtk:workflow" operation="get">   

    <select>          

      <node expr="@label"/>

      <node expr="@internalName"/>

    </select>   

    <where>     

      <condition expr="[operation/@internalName] = 'OP125'"/>   

    </where> 

  </queryDef>)

var res = query.ExecuteQuery()

logInfo("///// My Label: " + res.@label)

Could you please help me with this issue?

Thank you,

Marcin

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

david_garcia1

MVP

Avatar

david_garcia1

MVP

david_garcia1
MVP

03-08-2017

Hey Marcin,

Sorry I've forgot to include the brackets

      <condition expr={"@internalName = '"+intName+"'"}/>

also

If you use the following loop you can get an idea of the object keys available to you.

In the objects value, try also; task, task.workflow

Shall give you something like

javascript_test.JPG

so by doing logInfo(instance.label); It gives me the workflow title (screenshot https://db.tt/c1JVowRuhd )

Try playing around with these objects, not sure how to get the campaign name, because i am testing it on a normal workflow.

Answers (2)

Answers (2)

Avatar

Avatar

marcinkacz

Avatar

marcinkacz

marcinkacz

03-08-2017

Thank you for your response. Unfortunately this script returns error:

error_intName.PNG

Will you be so kind and give me some clues why?

BTW Do you know how to insert value into var intName dynamically? I mean, how to insert current campaign's internal name there?

Thanks,

Marcin

Avatar

Avatar

david_garcia1

MVP

Avatar

david_garcia1

MVP

david_garcia1
MVP

02-08-2017

<condition expr="[operation/@internalName] = '"+intName+"'"/>  

That is (') singlequote, then (") doublequote and +variable+