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

Determine the operation that triggered the business rule than decide if insert or delete the current record

depa
Tera Contributor

Hi everyone,

i have a business rule with a function which insert records into a table. Now i want to achieve determine on which operation triggers the business rule it should be decide between two different behaviors:

if(current.operation() == "update") {
  // delete current record and then insert with code in function getTimeDiff(); }
  if(current.operation() == "insert") {
    getTimeDiff(); }

I have wrote the behavior as a comment into the code.

Please let me know how can we accomplish this.

1 ACCEPTED SOLUTION

Mohit Kaushik
Mega Sage
Mega Sage

Hi Dape,

You can try the code something like this:

if(current.operation()=="update")

{

current.deleteRecord();

getTimeDiff();

}

else

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

{

getTimeDiff();

}

 

Please mark this answer correct if it resolved the query and mark it helpful too if it helped you at all.

 

Thanks,

Mohit Kaushik

Thanks,
Mohit Kaushik
ServiceNow MVP (2023-2025)

View solution in original post

2 REPLIES 2

Mohit Kaushik
Mega Sage
Mega Sage

Hi Dape,

You can try the code something like this:

if(current.operation()=="update")

{

current.deleteRecord();

getTimeDiff();

}

else

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

{

getTimeDiff();

}

 

Please mark this answer correct if it resolved the query and mark it helpful too if it helped you at all.

 

Thanks,

Mohit Kaushik

Thanks,
Mohit Kaushik
ServiceNow MVP (2023-2025)

Hi dape,

I saw you have marked my answer as correct. I am glad it worked for you, it will be great if you can mark the answer as helpful also.

 

Thanks,

Mohit Kaushik

Thanks,
Mohit Kaushik
ServiceNow MVP (2023-2025)