Expand my Community achievements bar.

SOLVED

Using variable inside <where> condition

Avatar

Level 4

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

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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.

View solution in original post

3 Replies

Avatar

Community Advisor

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

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

Avatar

Level 4

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

Correct answer by
Community Advisor

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.