current.operation() is null

Ken83
Mega Guru

Hello Community,

        Any reason why current.operation() would always be null in an email notification script? As I understand it, .operation() is a GlideRecord method. In the email script, current returns a GlideRecord of the current record. What am I missing here?

6 REPLIES 6

Chuck Tomasi
Tera Patron

Hi Kenneth,



The most common use of current.operation() I have seen is in business rules, where the system has already triggered the insert/update/delete/read action and the business rule is reacting to it.



With inbound email actions, no insert/update has taken place yet... that's what the action is trying to determine (what to do next) so current.operation() won't return anything until the current.insert() or current.update() has been triggered.


This is for an email notification script for an outbound email notification. When I create an Ad Hoc Request, it generates the notification, which runs the script. The notification is triggered by using the insert checkbox on the notification record. Would the current object, then not have access to that same event being performed on the record?


Sorry for the misunderstanding Kenneth. I missed that detail.



You are right, I would expect current.operation() to know what's going on in an outbound email script. I don't have an answer for you on that one, but I suspect support does. I'll be interested to hear what they have to say.


HI Service Portal - ServiceNow


Contact Support | ServiceNow


Brad Tilton
ServiceNow Employee
ServiceNow Employee

I don't believe current.operation() works asynchronously, and since the notification would be running asynchronously, I don't think it would have access to the type of operation that triggered it. Just like you don't have access to the previous object in an async.



You might have to do something like fire an event from a business rule and then pass the operation type as a parameter.