Flow Designer Trigger not being triggered correctly

mlamin
Giga Guru

Hello,

 

I am working on a Flow for a HRSD Process. I have an lifecycle event which has an HR service configured to go through a process. The HR service is configured to just create a new Case and the Flow will take it from there. Once the case is created, the Flow is supposed to be triggered base on the HR Service that created that case. and it should run the actions I will add. I have configured my flow to trigger on a created, with the condition of the HR service being the one in the lifecycle event. When I test the Flow in the designer, it seems to reach the case and goes through the actions. When I activate the flow it it not triggered at all.

 

Some Trouble Shooting: I noticed that when I pick a case that does not meet the condition, the flow also excutes which is making me wonder if my trigger is not setup correctly.

 

Please see pictures and advise how I can solve this issue.

1 ACCEPTED SOLUTION

Sandeep Rajput
Tera Patron
Tera Patron

@mlamin Since your flow is not triggering on the case creation on its own, there is a workaround to fix this issue which can be applied.

 

1. As a part of the first step, you can create a business rule on HR Core case table (sn_hr_core_case) and it should be onAfter  Insert business rule. Add a condition where HR Service is <Your HR Service Name> this will make the business rule to trigger only when the HR Service is the Service where you would like to trigger the flow.

 

Screenshot 2023-09-10 at 10.35.43 PM.png

2. In step 2, before moving on to the Advanced tab, open the flow designer in a separate tab and open your flow.

 

Screenshot 2023-09-10 at 10.39.09 PM.png

3. Open the context menu and choose Create code snippet option.

 

Screenshot 2023-09-10 at 10.39.45 PM.png

Put this code in advanced tab of the business rule created in step 1.

 

Screenshot 2023-09-10 at 10.41.10 PM.png

Since you need to provide the current record as input in the flow, make the following changes in the script.

 

 

(function executeRule(current, previous /*null when async*/ ) {

    // Add your code here
    (function() {

        try {

            // Start Asynchronously: Uncomment to run in background.
            // sn_fd.FlowAPI.getRunner().flow('sn_hr_core.sample_flow').inBackground().run();

            // Execute Synchronously: Run in foreground.
            var inputs = {};
            inputs['current'] = current; // GlideRecord of table:
            inputs['table_name'] = current.getTableName();

            sn_fd.FlowAPI.getRunner().flow('sn_hr_core.sample_flow',inputs).inForeground().run();

        } catch (ex) {
            var message = ex.getMessage();
            gs.error(message);
        }

    })();
})(current, previous);

Make sure to replace flow name in the following line here it is mentioned as sample_flow

 

 

            sn_fd.FlowAPI.getRunner().flow('sn_hr_core.sample_flow',inputs).inForeground().run();
​

 

Save the BR and create another case to see if the flow triggers.

 

Hope this helps.

 

View solution in original post

10 REPLIES 10

michaelj_sherid
ServiceNow Employee
ServiceNow Employee

@mlamin My first thought is to see what can be done to keep the process within the Lifecycle event engine itself instead of trying to use flow. I am under the assumption there are some dynamics that is warranting the use of flow.  With that said, the first thing I would do is to use the fulfillment type of Flow then you can use the Flow field to select the flow you created. This should engage the trigger to start the flow you created.  I would start there, but keep us updated on the progress.

 

Regards,

Mike

Thank you for the response. My reason for using flow instead of keeping the process within lifecycle event engine is that I could not find a way to go about my process in life cycle it was easier to setup my process in flow designer.

 

My process is that I would like an HR service to initiate an approval task that will be sent to a group to verify a procedure being started. once approved, I would like the procedure to get started by initiating a document template to assign tasks to users in an order to have them fill out a document. All of these were easily setup in flow but is not getting triggered is the issue.

 

I will try and use flow as a fulfillment type and see if that triggers it. If I use flow as a fulfillment and my trigger relies on a new specific HR service being created condition. does that trigger now have to change?

@mlamin Yes, the condition would need to change if you introduced a new HR Service.

 

Regards,

Mike

Hello, I tried adding the adding the flow as a fulfillment but I am a little confused on how I would have it triggered when it is added as an activity. please see images on how I configured it.