Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

HR Service - Fulfillment Type = Service Activity - Conditional Service Activities Possible?

Not applicable

Hello.  Within an HR Service, if my Fulfillment Type is set to "Service Activity", is there any way to have Approval or Task records triggered conditionally?  Or do I have to switch to "Flow"?

 

Many of our HR Services have Category and Subcategory variables, and we only want the Service Activities kicking in when certain Category or Subcategory values are specified by the end user.  Thanks.

1 ACCEPTED SOLUTION

Not applicable

I discovered that for HR Services you CAN use the very convenient (and simple) Fulfillment type of "Service Activity" and you can still have the HR Tasks generated CONDITIONALLY, as follows:

 

Setup a "Before Insert" type business rule on table "sn_hr_core_task".  Check the advanced checkbox and write a script which checks for whatever conditions you want, such as:

     Short Description (of the task) = X

     HR Task Type = Y

     Parent Case . Field Whatever = Z

 

Then, if the conditions are NOT MET, use the current.setAbortAction(true) command to abort the entire Insert operation.  This will cause the task to NOT be inserted, and ServiceNow will simply move on to the Next task in the ordered list.

 

Here is example:

z22.png

 

Please mark as helpful.

View solution in original post

4 REPLIES 4

Sandeep Rajput
Tera Patron

@Community Alums Since there is no way conditions can be specified with Service Activities, your best bet would be to chose the fulfilment type as flow/workflow.

Not applicable

I discovered that for HR Services you CAN use the very convenient (and simple) Fulfillment type of "Service Activity" and you can still have the HR Tasks generated CONDITIONALLY, as follows:

 

Setup a "Before Insert" type business rule on table "sn_hr_core_task".  Check the advanced checkbox and write a script which checks for whatever conditions you want, such as:

     Short Description (of the task) = X

     HR Task Type = Y

     Parent Case . Field Whatever = Z

 

Then, if the conditions are NOT MET, use the current.setAbortAction(true) command to abort the entire Insert operation.  This will cause the task to NOT be inserted, and ServiceNow will simply move on to the Next task in the ordered list.

 

Here is example:

z22.png

 

Please mark as helpful.

@Community Alums This solution is not scalable as there could be many such conditions associated with different HR Services and if you try to cover them via different business rule then the performance of your instance will take a hit.

 

Also, current.setAbortAction(true) results in an error message "Invalid update" on screen which may confuse your users.

Not applicable

I think it will be fairly easy to maintain, and can all be done in a single business rule.  I think that's a small price to pay since we do not want to be forced into much more complicated Flow technology.  Performance impact will be negligible.

 

I did not see any "Invalid Update" message during my testing.