How we can initiate a flow from ui action?

jobin1
Tera Expert

Hi Team,
How can we initiate a flow using ui action I tried below, but it's not working.

 

ui action script -runs on serviceside

(function executeAction(current) {
    // Set approval to 'Requested'
    current.approval = 'requested';
    current.update();
var ritmNumber = current.number;
  gs.log("inputsvalue0" +ritmNumber);
     var inputs = {
        ritmNumber:ritmNumber
    };
   

    // Log the input being sent to the flow
   gs.log("inputsvalue" + JSON.stringify(inputs));
    // Start the flow
    var flowAPI = new sn_fd.FlowAPI();
    flowAPI.startFlow('request_approve_flow1', inputs, gs.getUserID());
})(current);
9 REPLIES 9

Hi Ankur
flow is published
so i need to use the provided script  in ui action script right?
after that do i need  do i need to add or modify anything in flow?
scope:
Basically once's the ui action clicked then the flow should trigger i tested flow using test option manually the flow is working





 

@jobin1 

use create code snippet, get that code and add that in UI action

update your script with the correct inputs

We don't know your sub-flow is in global or some other scope and also the name of the inputs.

So you are the best judge here.

I just shared show the UI action script might look like, please enhance it further

I believe I have answered your question

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

Hi Ankur
i am getting  below log

var ritmNumber = current.number;
       gs.log("inputsvalue0" + ritmNumber)


but json structure log is not coming for RIM its empty 
gs.log("inputsvalue" + JSON.stringify(inputs));

@jobin1 

what came in log?

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

You can just put the copied code snippet in ui action. That's it.