Calling a flow designer from a workflow

Snow-Man
Tera Contributor

Hello guys, I have a flow designer that triggers when a knowledge article record is created but I want to call this flow designer in a workflow because ootb we have a mandatory field on knowledge base record to only add workflows. 

 

could you provide me with the necessary run script that I can add in a workflow to call my flow designer?

I am new to workflows.

 

Thanks in advance,

snow man

 

2 REPLIES 2

Mani A
Tera Guru

Open your flow  designer and Right side..we have a option to select code snippet and paste the logic in workflow and make changes for inputs with dynamic value

New Developer_S
Giga Sage

@Snow-Man 

To call a Flow Designer from a workflow in ServiceNow, you can use the "Run Script" activity within the workflow and write a script to trigger the flow programmatically. Here's how you can do this using a GlideRecord to fetch the Knowledge Article record and trigger the flow:

// Define the flow's unique sys_id and the knowledge article record
var flowSysId = 'YOUR_FLOW_SYS_ID'; // Replace this with your Flow Designer sys_id
var knowledgeArticleSysId = current.sys_id; // Get the sys_id of the current knowledge article record

// Set up inputs for the flow, if needed
var inputs = {
// Add any input variables expected by your flow here
'recordSysId': knowledgeArticleSysId
};

// Trigger the Flow Designer using the FlowAPI
try {
var flowAPI = new sn_fd.FlowAPI();
var execution = flowAPI.startFlow(flowSysId, inputs);

if (execution) {
gs.log('Flow started successfully for knowledge article: ' + knowledgeArticleSysId);
} else {
gs.log('Failed to start the flow for knowledge article: ' + knowledgeArticleSysId);
}
} catch (ex) {
gs.error('Error starting the flow: ' + ex.message);
}

 

if my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.