delay in ui action button after clickin on it

mr_Bhaskar
Tera Contributor

i have an ui action button in my workspace when i click on that it is activating after some delay in the work space how can i remove that delay

1 ACCEPTED SOLUTION

@mr_Bhaskar 

the delay is because of this line, in this line you are calling subflow and using inForeground() so it will wait till the time subflow completes and then the next line will execute

I believe you want it to run in foreground because based on response you are doing something.

var flow_result = sn_fd.FlowAPI.getRunner().subflow('x_simet_cmdb.deactivate_sims').inForeground().withInputs(inputs).run();

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

View solution in original post

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

@mr_Bhaskar 

did you check code of that if delay is added via some script?

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

mr_Bhaskar
Tera Contributor

yes i used

api.trigger("RECORD#REFRESH");
to run in workspace i was facing this issue in my workspace only
is there any thing i can do with workspace client script to eliminate the delay
  

mr_Bhaskar
Tera Contributor

Apart from that i didn't added any delay in the script

var getSimChangeFlow = gs.getProperty('x_simet_cmdb.toggle_sim_change_workflow');
if (getSimChangeFlow === 'true') {
    var grTemplate = new GlideRecordSecure('sys_template');
    if (grTemplate.get('name', 'Deactivation for SIM Inventory')) {
        var templateSysId = grTemplate.sys_id;
        var simIDArr = [current.iccid.toString()];

        var s = new x_simet_cmdb.simetricScriptedAPIHelper();
        var result = s.createSimChangeRequest(templateSysId, simIDArr);

        // Display Change Request Link
        var changeRec = new GlideRecordSecure('change_request');
        if (changeRec.get(result.change_sysid)) {
            var link = '<a href="change_request.do?sys_id=' + changeRec.sys_id + '">' + changeRec.number + '</a>';
            var message = gs.getMessage("Change Request: " + link + " created.");
            gs.addInfoMessage(message);
        }
    }
} else {

    try {
        var inputs = {};
        var sys_alias_gr = new GlideRecord('sys_alias');
        sys_alias_gr.get('8ac9201747f40610be52f442736d43ce');
        inputs['connection_alias'] = sys_alias_gr; // GlideRecord of table: sys_alias
        var iccid = [];
        iccid.push(current.iccid.toString());
        inputs['cmpid'] = current.connection_guid; // String
        inputs['sim_ids'] = JSON.stringify(iccid); // Array.String

        var flow_result = sn_fd.FlowAPI.getRunner().subflow('x_simet_cmdb.deactivate_sims').inForeground().withInputs(inputs).run();
        var outputs = flow_result.getOutputs();
        var response = outputs['response']; // String

        if (response.indexOf('Failure') > -1) {
            gs.addErrorMessage('Error in deactivating SIM.');
        } else if (response.indexOf("Success")) {
            gs.addInfoMessage('SIM ' + current.iccid + ' Deactivated successfully.');
            if (typeof window !== 'undefined' && window.NOW && window.NOW.PaneManager) {
                // This runs in Workspace
                api.trigger("RECORD#REFRESH");
            }
        }
        current.update();

    } catch (ex) {
        var messages = ex.getMessage();

    }

}
action.setRedirectURL(current);
for your reference
 

@mr_Bhaskar 

the delay is because of this line, in this line you are calling subflow and using inForeground() so it will wait till the time subflow completes and then the next line will execute

I believe you want it to run in foreground because based on response you are doing something.

var flow_result = sn_fd.FlowAPI.getRunner().subflow('x_simet_cmdb.deactivate_sims').inForeground().withInputs(inputs).run();

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