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

Natan F Rosa
Kilo Guru

Hi @JakubUs 

If you are using a custom widget or script that calls this UI Action, make sure the calling method (e.g. spModal, spUtil, nowapi, or other) is not being executed more than once.

Review console logs in your browser to see if the HTTP request is happening multiple times.

Have you been able to test this to validate this?

Please mark my answer as correct if this helped in any way.

Hello @Natan F Rosa,

 

No custom widget, just the default button, which shows up when "Form button" is selected.

@JakubUs  we should try adding some logs before
var result = sn_fd.FlowAPI.getRunner().subflow('global.name_of_the_flow').inForeground().withInputs(inputs).run();

to see if it's passing through here more than once before investigating other places.

@Natan F Rosa seems like the amount of times it is passing through that point is consistent with how many times the Subflow has run.
So on backend:
1 click on UI action -> passing through once -> 1 subflow context
In Portal:
1 click on UI action -> passing through 3 times -> 3 subflow contexts