Event parm 1 and parm 2 are both inactive - how to send to a default address

Nen
Tera Guru

Hi All,

I have a working script wherein I'm sending an email to the recipients from the event fired. I have both the Event parm 1 contains recipient and Event parm 2 contains recipient checboxes checked. I know that inactive users will not be able to receive the emails and I noticed that when both recipients from the event parameters are inactive, the certain iteration will be "skipped" (no email will be sent out). Is it possible to have a default "To" recipient for this case?

I'm adding a Cc on the mail script but I'm assuming an email will not be sent out when it has no "To" recipient even if it has a "Cc" that's why that certain email is being skipped.

Thanks!

1 ACCEPTED SOLUTION

Hi,

That's the correct approach.

So first do the check of the values of the group and user.

If both are inactive, then you will trigger the event like below

gs.eventQueue("your_event", gr, "static_email","group_and_user");

Make both group and user concatenate with some delimiter "-".

if one of them is active, then do like below.

gs.eventQueue("your_event", gr, "group","user");

Then in your notification, have both parm1 and parm2 are recipients.

And in your mail script, do something like this.

 

var parm2 = event.parm2;

parm2=parm2.split("-");

if(parm2.length>1) {

//then it means both are inactive, so group contains in parm2[0] and user value contains in parm2[1]

}

Mark the comment as a correct answer and also helpful if it solves your problem.

View solution in original post

9 REPLIES 9

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Yes email won't be sent to cc unless To recipient is present,

so in the email notification you can configure whom to send and select some default user

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Dubz
Mega Sage

Do a check on the users before you pass them through in the eventQueue, if they're both inactive pass the default user you want to send to.

 

Hi. Thanks for the reply. I am passing a group for the parm1 and a user for the parm2. I've tried checking if both are inactive but I still need to pass the group and user (as well as the default email address where I want to send the email) since I'm using the group and user in a different query on my mail script.

I've thought of storing the group and user on an array and use them as parm1 and use the default email add as the parm2. If both are inactive, then I'll have values for both parm1 and parm2. But if not, only the parm1 will have a value. So far I've been successful in passing it to the script but I'm having trouble checking the values so I can have different steps for each scenario

asifnoor
Kilo Patron

Hi,

One option is before you trigger a event from the script, check if the users in event parm1 or 2 is active or not. If both are inacctive, then pass static email in parm1.

Another option is in the notification, you can provide a static email (under users.. when you open users field in Who to receive tab), you will have a text field to enter the email address to which you want to send notification.

Mark the comment as a correct answer and also helpful if it helps.