Why do I get null in async on insert and delete business rule?

John_123_Snow
Mega Expert

find_real_file.png

(function executeRule(current, previous) {

gs.log(current.operation());

})(current, previous);

any reason why do I get null for current.operation() ? what I see online it should work but it doesnt.

 

1 ACCEPTED SOLUTION

Allen Andreas
Administrator
Administrator

Hi,

When trying to test this for myself, I saw this pop up below my code:

find_real_file.png

So, per that, async delete rules won't have access to current...because the record is deleted and gone, thus it can't know the operation.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

8 REPLIES 8

Hi,

I just wanted to check-in on this. If my reply above helped guide you correctly, if you don't mind, please mark it as Helpful & Correct.

Thank you!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hi

Instead of async, do it in before delete where you can access table_sys_id and pass it to the 3rd party API.

Mark the comment as a correct answer if this answers your question.

Willem
Giga Sage
Giga Sage

It says it in the script:

find_real_file.png

/*null when async*/

Meaning both previous and current will return null when you run the script asynchronous.

That "null" information is only talking about "previous" in async, which is true, it will be null and you don't have access to it.

Current is still available in Async: https://hi.service-now.com/kb_view.do?sysparm_article=KB0687840

The problem here is that it's current and delete....and async, which only then is current not available in async.

Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!