The CreatorCon Call for Content is officially open! Get started here.

How do I pass the Sys ID of the current Business Application in a UI Action to a Flow

matthew_hughes
Kilo Sage

I've got a UI action called 'Inherit parent BIA outcomes' on a business application form:

 

matthew_hughes_0-1739462664689.png

 

The code within the UI Action is:

inherit();

function inherit() {
    var busApp = new GlideRecord('cmdb_ci_business_app');
    if (busApp.get(current.sys_id)) {
        busApp.u_record_condition = 'bia_approval';
        busApp.update();

       try {
        var inputs = {};
        inputs['current'] = busApp; // GlideRecord of table:  
        inputs['changed_fields'] = busApp.u_record_condition; // Array.Object
        inputs['table_name'] = 'cmdb_ci_business_app';

        // Start Asynchronously: Uncomment to run in background.
        // sn_fd.FlowAPI.getRunner().flow('global.lbg_bia_refresh_update_inherited_bia_logic').inBackground().withInputs(inputs).run();
               
        // Execute Synchronously: Run in foreground.
        sn_fd.FlowAPI.getRunner().flow('global.copy_of_lbg_bia_refresh_update_inherited_bia_logic').inForeground().withInputs(inputs).run();
       
    } catch (ex) {
        var message = ex.getMessage();
        gs.error(message);
    }
}

action.setRedirectURL(current);
}
 
However, what I'm wanting to do is pass the Sys ID of the current Business Application into my flow in Flow Designer, but I'm not too sure how to do this. I'm wanting to pass the Sys ID into my flow variable called 'child Sys ID' and possibly use it in the trigger:

matthew_hughes_1-1739462877703.png

 

Can anyone guide me on what I need to do pass the Sys ID of the current Business Application into my flow so that the flow runs when the user clicks on the UI Action?

 

9 REPLIES 9

Gaspy
Tera Contributor

The question comes down to, what exactly you're trying to accomplish in clicking, "'Inherit parent BIA outcomes". In clicking, does it update the record itself? Does it update a child record? Does it create a new record? 

Regardless, I think using GlideAjax and a script include makes more sense, if you're going to be updating any data within the server. Within the Script Include, you can query any tables/records within the server and update as deemed necessary. 

If you've never done a glideAjax before this is a really helpful resource to walk you through - https://www.servicenow.com/community/developer-articles/glideajax-example-cheat-sheet-updated/ta-p/2...

Hi @Gaspy By clicking on 'Inherit parent BIA outcomes', it updates the existing business record that the UI Action is coming from. It does also require approvals, which is why I've done it as a flow designer.

Ankur Bawiskar
Tera Patron
Tera Patron

@matthew_hughes 

Can you check your earlier question? Seems you marked your own response as correct

How to apply a SYS ID from a piece of code within the Look Up record action of flow designer? 

AnkurBawiskar_0-1739526011369.png

 

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

Ankur Bawiskar
Tera Patron
Tera Patron

@matthew_hughes 

unfortunately you cannot pass inputs to flow.

You can only do this with subflow.

So please create a subflow from your existing flow and then pass the input

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