- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2023 07:11 AM
Hello Experts,
A RITM can have a workflow or a flow or no flow attached to it. Is there any way we can check via server side script whether the RITM is being triggered by a Workflow or a flow designer flow or normal one(means no flow attached)?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2023 10:29 AM
@deepika46 If a flow is attached with a record, it has a corresponding entry in sys_flow_context table, if a workflow is attached with an RITM an entry is made in wf_context table. You can use the following script to identify if there was a flow/work flow/none of them was attached with a record.
var now_GR = new GlideAggregate("sys_flow_context");
now_GR.addQuery("source_record", "436c8d344732211092c98021336d43aa"); //Replace with the sys_id of your RITM
now_GR.addAggregate('COUNT');
now_GR.query();
var flowCount=0;
if (now_GR.next()) {
flowCount=now_GR.getAggregate('COUNT');
}
var nowGR = new GlideAggregate("wf_context");
nowGR.addQuery("id", "436c8d344732211092c98021336d43aa"); //Replace with the sys_id of your RITM
nowGR.addAggregate('COUNT');
nowGR.query();
var workFlowCount=0
if (nowGR.next()) {
workFlowCount=nowGR.getAggregate('COUNT');
}
if(flowCount==0&&workFlowCount==0){
gs.info('Record does not have any flow/workflow associated with it');
}
else{
gs.info('Flow count '+flowCount+ ' workflow Count '+workFlowCount);
}
Please do not forget to mark this answer as correct and helpful if it manages to answer your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2023 07:18 AM
Hi @deepika46 ,
I don't think u would require any scripting to fetch this information. You can just create a report on RITM table and then u can dot walk using item field to Workflow & flow field l. You can bring these 2 fields in the report by dot walking from item field.
Then whichever RITM have empty value in both fields then there is no flow or workflow attached to it. Which ever had u will get the flow or workflow name.
Hope it helps
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2023 07:32 AM
i know that but there is a requirement that actually requires me to script. i have to cancel the workflow for RITMs. Now the cancel workflow() will only work where workflow is attached for RITM , not where flow is attched

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2023 10:29 AM
@deepika46 If a flow is attached with a record, it has a corresponding entry in sys_flow_context table, if a workflow is attached with an RITM an entry is made in wf_context table. You can use the following script to identify if there was a flow/work flow/none of them was attached with a record.
var now_GR = new GlideAggregate("sys_flow_context");
now_GR.addQuery("source_record", "436c8d344732211092c98021336d43aa"); //Replace with the sys_id of your RITM
now_GR.addAggregate('COUNT');
now_GR.query();
var flowCount=0;
if (now_GR.next()) {
flowCount=now_GR.getAggregate('COUNT');
}
var nowGR = new GlideAggregate("wf_context");
nowGR.addQuery("id", "436c8d344732211092c98021336d43aa"); //Replace with the sys_id of your RITM
nowGR.addAggregate('COUNT');
nowGR.query();
var workFlowCount=0
if (nowGR.next()) {
workFlowCount=nowGR.getAggregate('COUNT');
}
if(flowCount==0&&workFlowCount==0){
gs.info('Record does not have any flow/workflow associated with it');
}
else{
gs.info('Flow count '+flowCount+ ' workflow Count '+workFlowCount);
}
Please do not forget to mark this answer as correct and helpful if it manages to answer your question.