Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Find out how many flows use a subflow?

Stefan_Garcia
Tera Contributor

Is there a way to see how many flows use a subflow? Similar to the "Contained by" count on Roles or Variable Sets.

1 ACCEPTED SOLUTION

Riya Verma
Kilo Sage

Hi @Stefan_Garcia ,

Hope you are doing great.

 

To determine the number of flows that use a specific subflow, we can execute a database query to fetch the relevant records. elow is an example of how you can accomplish this using a GlideAggregate query:

var subflowSysId = 'INSERT_SUBFLOW_SYS_ID_HERE'; // Replace with the sys_id of the subflow you want to check

var flowCount = 0;

var gr = new GlideAggregate('wf_subflow');
gr.addQuery('subflow', subflowSysId);
gr.addAggregate('COUNT');
gr.query();

if (gr.next()) {
  flowCount = gr.getAggregate('COUNT');
}

gs.info('Number of flows using the subflow: ' + flowCount);
Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Regards,
Riya Verma

View solution in original post

3 REPLIES 3

Mallidi Suma
Tera Guru

Hi @Stefan_Garcia ,

 

You can find the above information in this table "sys_hub_sub_flow_instance". You can find both Flow and its associated SubFlow in this table.

 

Please mark my answer as helpful and accept it as a solution, if it helps!!

Why is this not the accepted solution? This is so simple and definitely the easiest and best solution - thanks!

Riya Verma
Kilo Sage

Hi @Stefan_Garcia ,

Hope you are doing great.

 

To determine the number of flows that use a specific subflow, we can execute a database query to fetch the relevant records. elow is an example of how you can accomplish this using a GlideAggregate query:

var subflowSysId = 'INSERT_SUBFLOW_SYS_ID_HERE'; // Replace with the sys_id of the subflow you want to check

var flowCount = 0;

var gr = new GlideAggregate('wf_subflow');
gr.addQuery('subflow', subflowSysId);
gr.addAggregate('COUNT');
gr.query();

if (gr.next()) {
  flowCount = gr.getAggregate('COUNT');
}

gs.info('Number of flows using the subflow: ' + flowCount);
Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Regards,
Riya Verma