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

accessing notification type from inside an email script

JP56
Kilo Contributor

Hello, 

I've got no way of knowing how to even approach a problem like this.

Say I've got an email script that needs to dynamically change based on what notification it was sent out in.

e.g. a script named metadata

If a "Incident has been assigned to you" notification is sent out, I want to have an if conditional in the JS that prints X.

If a "Incident has been opened on your behalf" note is sent, I want to have the script print Y.

 

The data itself is easy to get, the js is easy to write, but I genuinely have no idea how to access the type of notification sent from within the script itself.

 

If possible, could someone quickly detail how I might find such data in general? As an example, :

/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event

I'm presuming the data is held in the event GlideRecord, but how would I access it? Is there a list of fields in there somewhere?

1 ACCEPTED SOLUTION

Masha
Kilo Guru

I believe email_action gives you access to the notification record (sysevent_email_action table). You should be able to dot-walk to the notification record that is being used for the email from there.

See oob email script called (lines 3 and 26): incident_take_me_to_the_incident for usage example.

find_real_file.png

View solution in original post

8 REPLIES 8

Masha
Kilo Guru

I believe email_action gives you access to the notification record (sysevent_email_action table). You should be able to dot-walk to the notification record that is being used for the email from there.

See oob email script called (lines 3 and 26): incident_take_me_to_the_incident for usage example.

find_real_file.png

JP56
Kilo Contributor

Thanks, this seems to be it, one follow-up:

Where would I find a list of variables accessible through the email_action parameter? Like, if a person entered this system without knowing anything about how Servicenow does their stuff, how would they find out that "name" is a variable inside email_action?

hey ,

if you find my answer correct.

please mark Correct!

 

thanks,

shrutika surwade