Get Phone Number from user record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2015 09:57 AM
Hi Community,
I am trying to pull the requester's phone number from their file using the script below, however it's not working. Does anyone have any suggestions, as to what I am doing wrong here?
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) return;
if (newValue == "") {
g_form.setValue("phone", "");
return;
}
//Call Script Include to get User phone number
var ga = new GlideAjax("GetPhoneData");
ga.addParam("sysparm_name", "getUserphone");
ga.addParam("sysparm_user", g_form.getValue("new_phn_loc"));
ga.getXML(updatephone);
}
function updateLocation(serverResponse) {
//Process response from Script Include
var answer = serverResponse.responseXML.documentElement.getAttribute("answer");
g_form.setValue("phone", answer);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2015 10:02 AM
Hi Ciera,
Can you tell me that this client script is running onchange of which field, and also on which table.
And show the script include function also
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2015 10:04 AM
Try this
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) return;
if (newValue == "") {
g_form.setValue("phone", "");
return;
}
//Call Script Include to get User phone number
var ga = new GlideAjax("GetPhoneData");
ga.addParam("sysparm_name", "getUserphone");
ga.addParam("sysparm_user", g_form.getValue("new_phn_loc"));
ga.getXML(updatephone);
}
function updatephone(response) {
//Process response from Script Include
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue("phone", answer);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2015 10:05 AM
Hi Ciera,
On the line ga.getXML(updatephone) you are passing updatephone as the callback which does not exist. Try passing updateLocation which is the function name you created to be used as the callback.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2015 10:11 AM
Tried this but still doesn't work
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) return;
if (newValue == "") {
g_form.setValue("phone", "");
return;
}
//Call Script Include to get User phone number
var ga = new GlideAjax("GetPhoneData");
ga.addParam("sysparm_name", "getUserphone");
ga.addParam("sysparm_user", g_form.getValue("new_phn_loc"));
ga.getXML(updateLocation);
}
function updateLocation(serverResponse) {
//Process response from Script Include
var answer = serverResponse.responseXML.documentElement.getAttribute("answer");
g_form.setValue("phone", answer);
}