Subflow triggers multiple times from UI Action on Service portal

JakubUs
Tera Contributor

Hello Community,

 

I have a UI Action with settings in the screenshot.

JakubUs_0-1738866451031.png

The only purpose of the UI Action is to trigger Subflow with inputs from a record. This seems to work perfectly fine on backend, however in Service portal, for some reason the Subflow triggers several times. And it is not even consistent how many times. Most of the time it is three times, but I have seen anything from twice all the way to 6 times.

 

Am I doing something wrong? is there a way to limit the amount of times the Subflow triggers in portal or at least somehow restrict it from the Flow designer side?
Below is the script I the UI action is running:

(function() {

        var taskGR = new GlideRecord('sc_task'); 
        taskGR.get(current.sys_id);
        var deviceGR = new GlideRecord('alm_hardware');
        deviceGR.get(current.variables.asset);
        
        var inputs = {};
        inputs['task'] = taskGR;  
        inputs['device'] = deviceGR;

        var result = sn_fd.FlowAPI.getRunner().subflow('global.name_of_the_flow').inForeground().withInputs(inputs).run();
        var outputs = result.getOutputs();
    
})();

 

As a sidenote, I have noticed, that when I trigger the UI action from backend, the Calling source in the Subflow shows as "UI Action: name of the action" while when triggered from Service portal, the Calling source for each Subflow execution is "Background script". I am guessing that is normal, but I am still mentioning it just in case it isn't.

13 REPLIES 13

@JakubUs  Ok,
Is this subflow called in any other flow?

Maybe we can have a meeting to look at it together.

@Natan F Rosa It is not. Also, what I have noticed. The subsequent flows trigger roughly 5 seconds after each other. They are not all triggered at once.
And one more thing. When I impersonate certain users, it seems to work properly and the subflow triggers only once.

Hi @JakubUs 

In this case, I suspect something else

Does this flow perform updates?

I ask because there may be a Business Rule generating a cascade effect in this process.

Have you validated this possibility?

Please mark this answer as correct if it helps in any way.

Hello @Natan F Rosa ,

 

It does, but I also tried to put 5 minute timer as a first action, just to see if the Subflow starts even if nothing else is done and the Subflow triggers several times before the timer runs out. So the Subflow shouldn't be triggering any business rules.

Ankur Bawiskar
Tera Patron
Tera Patron

@JakubUs 

are you sure user is not clicking the button multiple times?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader