How to change "Opened for:Guest" on Inbound action "Create HR Case"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2023 01:18 AM
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:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2023 09:13 PM
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.