How to fetch the script (code) for all the JS activities within one workflow? | Community
Skip to main content
Level 2
February 27, 2024
Solved

How to fetch the script (code) for all the JS activities within one workflow?

  • February 27, 2024
  • 1 reply
  • 1271 views

Hi All,

 

I have 2 JS activities in one workflow (Workflow A). I am trying to fetch the script within both the JS activities in another workflow (Workflow B) using [activities/js/script] field from xtk:workflow data schema using the below code.

var res = xtk.queryDef.create( <queryDef schema="xtk:workflow" operation="select"> <select> <node expr="[activities/js/script]"/> </select> <where> <condition expr = {"@internalName = 'WKF123'"} /> </where> </queryDef>).ExecuteQuery();

 

However, I see that the script field stores the code for only one JS activity. Is it possible to fetch the code within all the JS activities in one workflow?

 

There is another issue that I'm observing. When viewed in the Data tab of the xtk:workflow table, the [activities/js/script] field displays the code for JS activity 1. Whereas, when I fetch the same field within another workflow, I see the code for JS activity 2. Can someone please help me understand this behavior?

 

Thank you in advance.

 

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 

 

The activities are stored as an array.

 

This how you can get the code.

var workflow=xtk.workflow.load(WORKFLOW_ID); var script1Code=workflow.activities.js[0].script; var script2Code=workflow.activities.js[1].script;

1 reply

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

Hello @anushka_rk 

 

The activities are stored as an array.

 

This how you can get the code.

var workflow=xtk.workflow.load(WORKFLOW_ID); var script1Code=workflow.activities.js[0].script; var script2Code=workflow.activities.js[1].script;
Manoj     Find me on LinkedIn
Level 2
February 28, 2024

Hi @_manoj_kumar_ ,

 

Thank you for your response.

It worked!

 

Kind Regards,

Anushka RK