Notification Triggered Before Business Rule Updates Field in Offboarding Lifecycle Event

GhitaB
Tera Contributor

Hi everyone,

I'm encountering a timing issue in the Offboarding lifecycle event in HRSD.

Here’s the scenario:

  • A notification is triggered when an Activity in the Offboarding lifecycle (specifically, the activity to confirm the Last Actual Working Date) is marked as complete.

  • After the activity is completed, a Business Rule runs, which copies the Last Actual Working Date into a custom field in the HR Profile of the employee (leaver).

  • The issue is that the notification is sent out a few seconds before the Business Rule completes its update.

  • As a result, the field value (Last Actual Working Date) is blank in the notification.

Has anyone faced a similar issue?
How can I make sure the field is populated before the notification is triggered?

Any suggestions are appreciated!

Thanks in advance!

4 REPLIES 4

Abbas_5
Tera Sage
Tera Sage

Hello @GhitaB,

 

The notification triggering before the business rule completes its update is a common issue in ServiceNow due to asynchronous processing. Notifications are usually triggered immediately after an event, while business rules may take a moment to execute and update fields. To resolve this, consider delaying the notification or using a workflow to ensure the field is updated before the notification is sent. 
Elaboration:
  • Asynchronous Operations:
    ServiceNow events and business rules can run concurrently, and the notification may be triggered before the business rule's update is completed.
  • Delaying the Notification:
    You can add a slight delay to the notification script to allow the business rule to finish updating the field. 
     
  • Using a Workflow:
    You can create a workflow that executes the business rule and then triggers the notification, ensuring the field is updated before the notification is sent. 
     
  • Event Queue:
    In some cases, you can use the gs.eventQueue() method to trigger the notification, which allows you to specify a delay before sending the notification. 
     
Possible Solutions:
  1. 1. Delay the Notification:
    Add a script in the notification that waits a few seconds before sending the email.
  2. 2. Use a Workflow:
    Design a workflow that:
    • Completes the activity in the lifecycle event.
    • Executes the business rule to update the field.
    • Triggers the notification.
  3. 3. Use Event Queue:
    Instead of directly triggering the notification, use gs.eventQueue() to queue the notification and specify a delay before sending it.
  4. 4. Adjust Business Rule Execution:
    Ensure your business rule is configured to update the field as quickly as possible. 
     
By implementing one of these solutions, you can ensure that the notification contains the updated field value, providing a more accurate and complete notification experience. 
 
If this is helpful, please hit the thumbs button and accept the correct solution by referring to this solution in future it will be helpful to them.
 
Thanks & Regards,
Abbas Shaik

GhitaB
Tera Contributor

Hi thank you for the information, just a quick questioncan we  instead of activity ,create a business rule? or set a timer for the actvity 

I think your best choice is to update your trigger of your notification from "after activity x" to "when event xy fired".

In your Business Rule where you copy your last working day you should add the gs.eventQueue() command at the end to fill your event. With this solution your notification should trigger after the copying part.

 

if you want you could consider a different solution. you could change the trigger of your notification to watch the HR Profile Table and triggers when your field is updated and not empty. Or Create a new BR with the same trigger condition and do stuff. Its up to you.

The same solutions could be made with flow as abbas suggested. (create trigger on HR Profile -> Set an Fire Event action)

Its up to you.

Thank you so much