I would like to call a subworkflow from a campaign, send the campaign internal name to the subworkflow, and pull that into the subworkflow query which builds a report for that campaign that was passed to it.
What code can I add to the subworkflow script that would pull instance.operation.internalName
and then what code do I need in the Javascript activity in the subworkflow to pull out that internal name and pass it to the query?
Matthew
Views
Replies
Total Likes
Hi @n235ps ,
In the Configuration script section of the Sub-workflow activity, you can try to add the following code to pull the instance.operation.internalName:
// Retrieve the internal name of the campaign
vars.internalName = instance.operation.internalName;
// Now, you can use vars.internalName in the subworkflow to perform operations.
You can now reference vars.internalName anywhere within the subworkflow to build queries or generate reports.
Example Query:
var query = xtk.queryDef.create(
<queryDef schema="nms:delivery" operation="select">
<select>
<node expr="@internalName"/>
</select>
<where>
<condition expr={"[operation/@internalName]='"+vars.internalName+"'"}/>
</where>
</queryDef>
);
var result = query.ExecuteQuery();
// Further processing to build the report
Best regards,
MEIT MEDIA (https://www.meitmedia.com)
Contact Us: infomeitmedia@gmail.com
Thank you Meit.
I set a javascript activity
and added the code with a command to print to the log.
// Retrieve the internal name of the campaign
vars.internalName = instance.operation.internalName;
logInfo("raw internal name: " + instance.operation.internalName);
logInfo("campaign internal name master: " + vars.internalName);
// Now, you can use vars.internalName in the subworkflow to perform operations.
but I'm not getting a value for the campaign internal name as seen in the log.
Seems pretty straight forward and should be easy. What am I doing wrong?
Views
Replies
Total Likes
I'm not able to pull in instance variables in the sub workflow or a javascript activity in either location for code.
Matthew
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies