Expand my Community achievements bar.

Announcing the launch of new sub-community for Campaign Web UI to cater specifically to the needs of Campaign Web UI users!
SOLVED

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

Avatar

Level 2

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

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

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

Avatar

Level 2

Hi @Manoj_Kumar_ ,

 

Thank you for your response.

It worked!

 

Kind Regards,

Anushka RK