- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2017 08:27 AM
When ever i select Caller id i need to populate email, phone, manager name, & title, this i need to get using Script include.
PLEASE HELP ME OUT on this
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2017 09:09 AM
Hi,
For Auto population of the above defined Variables you can write an Script Include and call the same Script Include in an OnLoad Catalog Client Script as mentioned below:
Script Include:
var requestor_details = Class.create();
requestor_details.prototype = Object.extendsObject(AbstractAjaxProcessor, {
requestor_info: function() {
var result = this.newItem("result");
var logged_user = gs.getUserID();
var user_detail = new GlideRecord('sys_user');
user_detail.addQuery('sys_id',logged_user);
user_detail.query();
while(user_detail.next())
{
result.setAttribute("user",user_detail.sys_id);
result.setAttribute("phone", user_detail.phone);
result.setAttribute("email",user_detail.email);
result.setAttribute("location",user_detail.location);
}
},
type: 'requestor_details'
});
2) Then you can write an On Load Catalog Client Script wither on your Catalog Item or on the Variable Set to have the variables populated as shown below:
Script:
function onLoad()
{
var ga = new GlideAjax("requestor_details");
ga.addParam("sysparm_name","requestor_info");
ga.getXML(ajaxResponse);
function ajaxResponse(serverResponse) {
var result = serverResponse.responseXML.getElementsByTagName("result");
var phone = result[0].getAttribute("phone");
var user = result[0].getAttribute("user");
var email = result[0].getAttribute("email");
var loc = result[0].getAttribute("location");
g_form.setValue('requestor_phone',phone);
g_form.setValue('requestor_name',user);
g_form.setValue('Location_user',loc);
}
}
Replace your Variable Name appropriately in the Set Value Conditions say for example in place of the variable "Location_user" with your Location Variable.
In a Similar Way you can try for other Variables also.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2017 09:25 AM
Yes you can do it, Just modify the On load as per your requirement.
I'm going to recommend against putting a bunch of related fields on the form as a bad practice. Most of this information is available simply by hovering over the "i" icon next to the reference field. Unless you anticipate the user changing their department, customer unit, or something else during the request process (which isn't likely for most of this information) then I would leave it off the form. It's what reference fields were designed to do.
Thanks,
Rohith.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2017 09:57 AM
Rohith,
Everything is working fine only i have 2 doubts,
Under Location i can see Sys_id instead of display value, can you please let me know how to convert it into Displlay Value
Other is Can you please explain me below script in details what does Set Attribute does ? what is Resulg [0]
result.setAttribute("user",user_detail.sys_id);