logo

NJP

ServiceNow how to free up a flow with wait for message block by broadcasting the message

ServiceNow Blog · Nov 17, 2026 · article

ServiceNow how to free up a flow with wait for message block by broadcasting the message

see my other post ' ServiceNow flow waiting for another flow' post  http://www.cloudminus89.com/2026/07/servicenow-flow-waiting-for-another-flow.html

this mentions a community post:

https://www.servicenow.com/community/developer-blog/sending-message-to-an-active-flow-from-outside-of-context/ba-p/3194739 

in below code examples, the flow wait for message block is expecting a value of 'onboarding_flow_resume'

expanded:

option 1

if you know the workflow context, pass it

var wfcontext = <executing_context_sysid> + '';

var flowMsg = 'onboarding_flow_resume';

var res = sn_fd.FlowAPI.sendMessage(wfcontext, flowMsg, '');

option 2

if you don't know the workflow context, retrieve it using the source record sys id:

for this option, you need to pass the flow or sub flow name string

var ticketSysid ='<enter_sys_id>'; var grFlow = new GlideRecord('sys_flow_context');

grFlow.addQuery('state', 'WAITING');

grFlow.addEncodedQuery('source_record=' + ticketSysid + 'ORsource_record=' + reqplanSYSID);

grFlow.addQuery('name', '<flow or sub flow name>');

grFlow.orderByDesc('sys_created_on');

grFlow.query();

if (grFlow.next()) {

var contextId = grFlow.getUniqueValue();

var flowMsg = 'onboarding_flow_resume';

sn_fd.FlowAPI.sendMessage(contextId, flowMsg, '');

}

if you wanted to broadcast the message with parameters instead of empty string:

 sn_fd.FlowAPI.sendMessage(contextId, flowMsg, JSON.stringify({

param1: "xmasDay:false",

param2: "calledFrom:BusRuleViaScriptIncl"

}));

View original source

http://www.cloudminus89.com/2026/11/servicenow-how-to-free-up-flow-with.html