Solved! Go to Solution.
Views
Replies
Total Likes
Hi @StephenWa4
You can follow Parthasarathy tutorial or just download the package I added directly.
Thanks
Hi @StephenWa4
You can follow Parthasarathy tutorial or just download the package I added directly.
Thanks
@StephenWa4
Use Case:
You want to remove keepResult="true" from the root <workflow> tag in multiple workflows in bulk.
Approach:
1. Use xtk:workflow schema to query workflows (by internal name, folder, etc.)
2. Load each workflow's XML.
3. Remove the keepResult attribute from the root <workflow> tag (if present).
4. Save the updated XML back to the workflow.
Sample JavaScript Code (to run inside a JavaScript activity in a workflow):
//Java
// STEP 1: Query workflows based on internal name pattern or other conditions
var workflows = [];
var query = NLWS.xtkQueryDef.create({
queryDef: {
schema: "xtk:workflow",
operation: "select",
select: {
node: [
{ expr: "@id" },
{ expr: "@name" },
{ expr: "@internalName" }
]
},
where: {
condition: {
expr: "@internalName LIKE 'myWorkflowPrefix%'" // Replace with your desired filter
}
}
}
});
var result = query.ExecuteQuery();
workflows = result.workflow;
// STEP 2: Iterate through workflows and modify XML
for each (var wf in workflows) {
var wfId = wf["@id"];
var workflow = NLWS.xtkWorkflow.load(wfId);
var dom = new XML(workflow.xml);
// Check and remove keepResult="true" if present
if (dom.@keepResult == "true") {
logInfo("Removing keepResult from workflow: " + wf.@internalName);
delete dom.@keepResult;
// Save modified XML back to the workflow
workflow.xml = dom.toXMLString();
NLWS.xtkWorkflow.save(workflow);
} else {
logInfo("No keepResult to remove in workflow: " + wf.@internalName);
}
}
Recommendations:
- Replace 'myWorkflowPrefix%' with an actual filter matching the workflows you want to update.
- Consider backing up the workflow XML or cloning workflows before performing bulk updates.
- Add checks to ensure the workflow is not currently running (status = paused or stopped), if needed.
Have a nice day.
Thanongdach
Views
Replies
Total Likes
Views
Likes
Replies