To check the execution of a RITM

deepika46
Tera Contributor

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)?

1 ACCEPTED SOLUTION

Sandeep Rajput
Tera Patron
Tera Patron

@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.

View solution in original post

3 REPLIES 3

Danish Bhairag2
Tera Sage
Tera Sage

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

 

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

Sandeep Rajput
Tera Patron
Tera Patron

@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.