- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2020 07:29 AM
Hello,
We use the gs.createuser method within our Create Incident Inbound Email Action to create INC's for our service desk from external clients. This function is creating duplicate records on the sys_user table with the email being slightly different, the name being null or filled, etc. I also came across this documentation that says that the gs.createUser() method will no longer be supported: https://docs.servicenow.com/bundle/orlando-servicenow-platform/page/administer/notification/referenc...
am wondering what the best alternative to the gs.createUser Method is. The documentation mentions the getUserID method but that works with the currently logged in user which would not be applicable as we are only working with emails sent to our service desk from external clients.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2020 10:35 AM
Hi
Since you're already using the email property "Automatically create users for incoming emails from trusted domains", in order to avoid duplicate users, you can create a duplicate check business rule on the before insert of "sys_user" table, and check for an existing user using your unique user identifier (in your case if that's the email address), and abort the transaction if a user record is found. That way, your inbound logic would create users, and the before insert business rule shall prevent the creation of a duplicate user.
Steps:
Create a new business rule - Table : User (sys_user)
When to Run: select - Before, Insert;
Select "Advanced"
Under the "Advanced" tab, on Script section, use the below snippet:
(function executeRule(current, previous /*null when async*/) {
var user = new GlideRecord(current.getTableName());
if(current.email) {
user.addQuery('email', current.email.toString());
user.addActiveQuery();
user.query();
if (user.next() && user.sys_id != current.sys_id) {
gs.addInfoMessage("A user record with the same email address already exists in the system. Please deactivate/delete it first to create a new record.");
gs.info("Duplicate user email: "+current.email.toString()+" Aborting action...");
current.setAbortAction(true);
}
}
})(current, previous);
Thanks & Regards,
Rishabh Jha
Aavenir (https://www.aavenir.com/)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2020 06:38 AM
Hi Rishbah,
We're going to take a slightly different approach, filtering the emails in the advanced section of the inbound email action but thank you for your suggestions! They have provided us with useful info I did not know.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2021 11:08 AM
Hi Guys i would have a question probably you guys can for sure help me 🙂
How can i setup a UI Action in Agent Workspace to click a Button an then create a User Record in the sys_user table - Because we have a lot of customers and we are currently moving back from our old SM Tool Freshdesk and the data there is Useless.