How to change "Opened for:Guest" on Inbound action "Create HR Case"

Mayuko MURAMOTO
Tera Contributor

Hello, there.

 

I'd like to ask you how to change 'Guest' (Opened for) to HRSD Guest, which I generated, on "Create HR Case" of Inbound Action. 

I thought it was just ok to change the following script.

 

Before:

if (gs.getUserID() == '5136503cc611227c0183e96598c4f706') {        //GUEST SYS_ID
After:
if (gs.getUserID() == '<sysID that I made the user's> ') {        //HRSD GUEST SYS_ID
 
However, it doesn't work. "Opened for" and "Subject Person" are still "Guest".
Could anybody tell me how to change "Opened for" user, please?
 
Thank you in advance.
Sincerely yours,
Mayuko
 
1 REPLY 1

Max Dore
ServiceNow Employee
ServiceNow Employee

1. I would recommend before your IF to log gs.getUserID() because i think this is for when someone is logged in and inbound actions are processed without someone logged in, this means you would need to check for the email of the recipient and query the user table.

2. I assume you setting the value to the field afterwards? Can you post the whole script for us to see it?

 

If you don't need to do conditional statements, use the Field Actions to just set the opened for with the UI. No need for scripting.

 

If you do need to do some conditional statements (therefore scripting) to compare sysids in case the mailbox is tied to the guest user or something it would look more like this:

var grUser = new GlideRecord('sys_user');
grUser.addQuery('name', email.from);
grUser.query();
if(grUser.next()){
if(grUser.getUniqueValue() == '<sysID you need to compare with>') {
current.opened_for = <grUser.getUniqueValue() or a sysID>;
}
}

 

Also, when scripting it is better to use system properties instead of hardcoding sysIDs. Hardcoding sysIDs is not best practice and should be avoided.

More on system properties