How to pass the Sys ID of the current record from a UI Action into a Flow Designer

matthew_hughes
Kilo Sage

I've got the following UI Action that runs on the 'cmdb_ci_business_app' table:

matthew_hughes_0-1739373566638.png

 

What I'm wanting to do is trigger a flow in flow designer when the user clicks on the UI Action. I'm trying to use the below code to do this:

 

inherit();

// if check.found is true, a parent business application
// with populated BIA values has been found
function inherit() {
    var busApp = new GlideRecord('cmdb_ci_business_app');
    busApp.get(current.sys_id);
    busApp.u_record_condition = 'bia_approval';
    busApp.update();

    //var check = new LBGCheckBusinessApplication().parentHasBIAValues(current.sys_id);
   
    // Call the BIA utils which generates / updates the current workflow
    //var inheritUtils = new LBGBiaUtils();
    //inheritUtils.generateBIAApproval(current.getValue('sys_id') , "inherit" , '');

    (function() {
   
    try {
        var inputs = {};
        inputs['current'] = busApp.sys_id; // 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.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've released in my Flow Designer is that I don't want to use the trigger as other business applications could be affected rather than just the current one. I'm wanting my flow to trigger when the user clicks on the UI Action for that one specific application. At the moment, I'm trying to capture the Sys ID of the current business application like below:

 

matthew_hughes_2-1739373799840.png

 

I was just wondering if anyone knows where I'm going wrong and what I need to do to pass in the Sys ID of the current record so that I can get flow running for that one particular business application.

2 REPLIES 2

Sruthi17
Kilo Sage

 To pass the Sys ID of the current record from a UI Action, you can simply use "current.sys_id" and pass the "current.sys_id" value as input to the flow.

 

Then in flow designer, you can use the input (the sys_id) wherever required using the data pill picker

 

And if you want to update the fields in the current record you can do it simply like

 

current.u_record_condition = 'bia_approval';
current.update();
 
Please mark my answer as correct if it helps. Thanks

ok. For the first part of use "current.sys_id" and pass the "current.sys_id" value as input to the flow, how do I do that and where in my UI Action or flow would I need to make the amendments?