- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2018 10:53 AM
So I'm creating an application for an IT help desk. The idea is the customer will walk up to the help desk and swipe an RFID card. Through the application we will gain information like the users first name and last name or an email. With that email I want to use a URL to populate an incident report. like..
URL: https://<instance name>.service-now.com/nav_to.do?uri=incident.do?sys_id=-1%26sysparm_query=priority=1^incident_state=3^caller_id=abel.tuter^assigned_to=javascript:gs.getUserID()
For this IT desk the assigned to will be the currently logged in user. That works great with the above URL. I run into a problem when I want to get the caller. The caller will be the walk up customer.
So my question is what can I do to achieve what I'm going for? I will have access to the back end so I can write whatever need be to achieve this. Ideally there would be some work around with just the URL but if that does not work I'm open to whatever. I think it needs to be something like I would have a script that could search up an ID based on the callers name or email. I'm just unsure how to parse caller_id since it is a reference.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2018 10:06 AM
Here is the correct code
function onLoad(){
var id;
var cID ='';
var parmArr=getParmVal('sysparm_query').split("^");
for(i=0; i<parmArr.length; i++){
if(parmArr[i].indexOf("caller_id")>-1){
cID=parmArr[i].split("=")[1];
break;
}
}
var usr = new GlideRecord("sys_user");
usr.addQuery('email', cID);
usr.query();
if(usr.next()) {
id = usr.sys_id; //this will get you the sys_id of the user
}
if(id) {
g_form.setValue('caller_id', id);
}
}
function getParmVal(name){
var url = document.URL.parseQuery();
if(url[name]){
return decodeURI(url[name]);
}
else{
return;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2018 03:08 PM
Where are you storing the RFID info after customer swipes in?
You should get the users email from there and query user table to get the sysid of the user and thenn populate the URL.
I assume, helpdesk will click on a button/ui action. The UI action should have all the logic
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2018 04:53 PM
You can do a GlideRecord query to the user table based on the first name and last name you got from the RFID card.
var usr= new GlideReciord("sys_user");
usr.addQuery('first_name",<first name>);
usr.addQuery("last_name",<last name>);
usr.query();
if(usr.next()){
//usr.sys_id; //this will get you the sys_id of the user
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2018 08:21 AM
As a caveat I'm very new to service now. So if I was to do this would I write a server side function, and call it with a client side script that parses the URL for the information?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2018 08:24 AM
You can put this code in the client side as well. Can you post the code you have so that I can edit it for you
