Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Lifecycle event: attach a (sub?)flow and trigger it from the activity sets with parameters

Ward van Hoof
Mega Guru

Dear all,

On my personal dev I'm trying to automate part of the lifecycle activities by creating a flow which is triggered at a specific point in the activity set. However, I am not sure how to configure it. I checked the documentation (https://docs.servicenow.com/bundle/orlando-hr-service-delivery/page/product/human-resources/task/configure-hr-lifecycle-event-activity.html#configure-lifecycle-event-activity-flow) which is not very specific so i was hoping you could help me.

I can configure a lifecycle activity of type "flow". Do i attach a "flow" or a "subflow" to this activity? Both are available from the list.

If i attach a subflow without parameters, i get the error shown in screenshot 1 (incorrect parameter configuration).

I will, however, need to pass parameters of the case to the subflow. When i tried to configure parameters, the same error occured. WHen i attach a subflow with input parameters, i do not see how i can specify how parameters should be filled.
Is it possible that in the context of the subflow i have access to the current case record? How can i configure Input paramters on the subflow and fill them using the "lifecycyle activity"? 

If i have to use a regular flow, i would like to know how to trigger it. The flow needs a trigger of type "created" or "updated", if it is not a "service catalog" flow. However, i want to trigger the flow from a specific point in the life cycle events (triggered in a specific activity set). I do not think that a Flow on the HR Case table will trigger at the right moment if i select "update" with some conditions.

Could you guide me through the correct way to trigger a flow or subflow from a lifecycle activity?

Thanks in advance for your assistance.
All the best,

Ward van Hoof

 

1 ACCEPTED SOLUTION

Ward van Hoof
Mega Guru

I logged a HI ticket and this problem article was linked. Using the information below helped me to trigger the flow (though there's no relation from the flow to the case / activity which triggered it)

PRB1381783

In addition to the above issue, the The following additional limitations / issues have been identified:
1) Results in a runtime error if the configured Flow does not have "user" and "job" inputs defined (LE Activity configuration currently allows you to select any active, published flow including ones without these parameters).
2) Results in a runtime error if the configured Flow is not a Subflow (LE Activity configuration allows selection of both flows and subflows)
3) Default Inputs to the subflow for the parent case and lifecycle activity are missing, which would be relevant contextual information for many general use cases
4) There is no tracking mechanism in place to keep the Lifecycle Activity active while the subflow is still running

View solution in original post

12 REPLIES 12

In case you want to access the input values 'user' and 'job' of the subflow(triggered by the life cycle activity of type flow), you can do that using "fd_data.subflow_inputs.user"

 

PLEASE MARK THIS IS AS CORRECT OR HELPFUL IF THIS MAKES ANY IMPACT!

bvanh
Kilo Contributor

I came across this today. It doesn't look like its been fixed in Quebec. The code that calls the subflow is in the hr_ActivitySet script include, and there are only two inputs that are passed, 'user' and 'job'. At a minimum it should pass the sn_hr_core_case reference that triggered the lifecycle event i,e, parentCase. It looks like the user and job were only included to be able to call the out of the box subflow for "Switch primary job."

        var inputs = {};
        inputs['user'] = parentCase.getValue('subject_person');
        inputs['job'] = parentCase.getValue('subject_person_job');

 

 

GM5
Tera Guru

How do you access the HR case where this LifeCycle event activity is being riggered? I have a similar scenario, when a "Leave of absence" case is created an activity will run a flow, this flow or sublfow... need to update any other cases opened for the same subject person, will need to update the work notes with a hardcoded text + a date field on the "Leave of absence HR case"

 

I tried

var note = "This associate is currently on a leave of absence as of " + fd_data.subflow_inputs.job;
return note;
var note = "This associate is currently on a leave of absence as of " + fd_data.subflow_inputs.user;
return note;

 find_real_file.png

But nothing is returned after the plain text, customer want to use the flow feature on LIfeCycle events activities but so far this is a pain in the a... I want to give another chance to this before switching to the standard Flow and use the Trigger feature.