The CreatorCon Call for Content is officially open! Get started here.

In a business rule that runs on both insert and update, how can I determine, in the script section, if the record is being inserted or updated?

Rick Forristall
Tera Guru

I have an after business rule that runs on insert and update on the sys_user table. I create a new record in another table and need to check to see if the action on the sys_user table is an insert or an update.

How can I make that determination in the script section of a business rule.

For example: if the user record is being inserted, then I need to get the sys_created_on date for this record, If the user record is being updated I need to get the sys_updated_on date. Then I use this date for some comparisons.

Is there a way in the scripting section to make such a determination?

In the onBefore script for the LDAP User Import transform map there is a check using:

if (action == 'insert') ...

Does this work for business rules also?

1 ACCEPTED SOLUTION

Mike Patel
Tera Sage

try

if(current.operation() == 'insert')

 

More Info - https://docs.servicenow.com/bundle/kingston-application-development/page/script/business-rules/concept/c_DbActionsToTriggerTheBusRule.html

View solution in original post

3 REPLIES 3

Mike Patel
Tera Sage

try

if(current.operation() == 'insert')

 

More Info - https://docs.servicenow.com/bundle/kingston-application-development/page/script/business-rules/concept/c_DbActionsToTriggerTheBusRule.html

Thanks Mike!

One of the challenges of the SN documentation is asking the right question. Thanks for the answer and the link!!

 

Rick Forristall

Most of the methods on current object is available under GlideElement API in developer site. 

There are a few surprises (like current.operation) under GlideRecord API.