How to fetch the value for instance variables in a JS activity? | Community
Skip to main content
Level 2
February 27, 2024
Solved

How to fetch the value for instance variables in a JS activity?

  • February 27, 2024
  • 1 reply
  • 663 views

Hi All,

 

I would like to fetch the instance variable of workflow A in a JS activity in workflow B.

 

I have written the following code:

var workflowContent = xtk.queryDef.create( <queryDef schema="xtk:workflow" operation="select"> <select> <node expr="variables" alias="VariablesTab"/> </select> <where> <condition expr = {"@internalName = 'WKF123'"} /> </where> </queryDef>).ExecuteQuery(); logInfo("XML: "+workflowContent); for each(var row in workflowContent) { var wkfVariablesTab = row.VariablesTab; logInfo("Variables: "+wkfVariablesTab); }

 

logInfo("XML: "+workflowContent); populates the following result:

XML: <workflow-collection> <workflow> <VariablesTab running="false" running-type="boolean"/> </workflow> </workflow-collection>

 

However, wkfVariablesTab variable is empty. How can I retrieve the instance variable running ="false" running-type="boolean" in the wkfVariablesTab variable?

 

Kind Regards,

Anushka RK

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 Manoj_Kumar

Hello @anushka_rk 

 

instance variables are not stored and that is why you can get them by querying schema.

If you want  a value want it in workflow B, then there are 2 ways to do it.

  1. Pass the instance variable value to workflow B by using external signal activity. I am not sure if you are using external trigger for Workflow B
  2. Use Option instead of variables

 

1 reply

Manoj_Kumar
Community Advisor
Manoj_KumarCommunity AdvisorAccepted solution
Community Advisor
February 28, 2024

Hello @anushka_rk 

 

instance variables are not stored and that is why you can get them by querying schema.

If you want  a value want it in workflow B, then there are 2 ways to do it.

  1. Pass the instance variable value to workflow B by using external signal activity. I am not sure if you are using external trigger for Workflow B
  2. Use Option instead of variables

 

Manoj  | https://themartech.pro