Populate Requested for onchnage of Id and vice versa.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2023 02:43 AM
Hi All,
I have a requirement to show Id On change of Requested for.
I created a custom table u_custom_user and one field u_userid in that. I added a field in the user table name Id which is referencing to the u_custom_user.
In the catalog form there are two variable Requested for(reference- sys_user) and Id(Lookup select box- sys_user, lookup field value- Id).
On change of Requested for Id should populate and on change of Id Requested for should populate.
Please help in this.
Thanks!
Samiksha
- Labels:
-
Request Management
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2023 02:48 AM
you can use script include for this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2023 03:25 AM
I tried but it is not working.
Script Include
var requestor_details = Class.create();
requestor_details.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getCustomerId: function() {
var user = this.getParameter('sysparm_user');
var results = "";
var customer = new GlideRecord("u_custom_user");
customer.addQuery('u_userid', user);
customer.query();
if (customer.next()){
var cus= cost.u_user_id;
var users = new GlideRecord('sys_user');
users.addEncodedQuery("user_nameSTARTSWITH" + cus);
users.query();
if (users.next()){
results = users.u_idss.getDisplayValue();
}
return JSON.stringify(results);
}
},
type: 'requestor_details'
});
Client script
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var user_id = g_form.getValue('requested');
var ga = new GlideAjax('requestor_details');
ga.addParam('sysparm_name', 'getCustomerId');
ga.addParam('sysparm_user', user_id);
ga.getXML(EmployeeDetailsLookup);
}
function EmployeeDetailsLookup(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
var result = JSON.parse(answer);
alert(result);
g_form.setValue('id', result);
}
I am getting null on alert.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2023 03:56 AM
cost means because it does not get any value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2023 05:23 AM
Hi @Harish Bainsla,
I corrected the var value as customer. Still null is coming.