- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2022 03:24 AM
Hi Guys,
I need help with retrieving Name from sys_user table.
The scenario is, I am importing Headset information into servicenow. The way integration work is as soon as someone plugs in their headset ServiceNow picks up their headset information and records it in ServiceNow. User's laptop has a small software deployed via SCCM that picks the information and makes a REST call to ServiceNow Table and if no record is found for the device attached creates a new record.
The problem is the users are imported via Azure and the format of user name is username@domain.com.au but the user name format the software sends to servicenow via REST call is without @domain.com.au. What I want to achieve is pick the user name field from Table jabra_device and look up sys_user table, if sys_user contain username from jabra_device then update assigned to field in Jabra_device table with Name from Sys_user table.
The table below is the originating username table with no @domain.com.au
Table A
The sys_user table below is the one with username@yvw.com.au
Table B
Sorry apologies If I am not able to explain it clearly before, but in the simple terms, I want to find out if username from Table A exists in Table B and if it does grab Name from Table B and update Assigned to in Table A.
Thanks in advance.
Regards
Nasir
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2022 11:50 PM
Hi,
update as this
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord("sys_user");
gr.addEncodeQuery('user_nameLIKE' + current.user_name); // ensure you use correct field name from jabra table
gr.query();
if(gr.next()){
current.assigned_to = gr.getUniqueValue();
current.update();
}
})(current, previous);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2022 03:31 AM
Hi,
the user_name which your software is sending is without the domain name.
you can use that to query in sys_user against the user_name field and find if user is present or not
what script did you start with?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2022 04:00 AM
(function executeRule(current, previous /*null when async*/) {
var gr=new GlideRecord("sys_user");
gr.addEncodeQuery(user_nameLIKEcurrent.user_name); // Not Sure this Querry
gr.query();
if(gr.next()){
current.assigned_to = gr.name;
gr.update();
}
})(current, previous);
Hi Ankur,
I am not sure about the querry but this is what I got in the business rule.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2022 07:04 AM
any suggestions @Ankur
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2022 11:50 PM
Hi,
update as this
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord("sys_user");
gr.addEncodeQuery('user_nameLIKE' + current.user_name); // ensure you use correct field name from jabra table
gr.query();
if(gr.next()){
current.assigned_to = gr.getUniqueValue();
current.update();
}
})(current, previous);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader