auto populate manager details based on user selected in requested for field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2024 05:07 AM
Hi Community,
I have a requirement, in catalog form there is variable set in that there is 2 fields called
- Labels:
-
Request Management
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2024 05:24 AM
Hi @suuriya
List collector variable (common_vars_also_notif) must be referencing to some table (check in type specification).
Now when you have list collector referencing to table then from script it will be expecting a sys_id of records from its referenced table.
Thanks
dgarad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2024 05:26 AM
var Autopopulatemanager = Class.create();
Autopopulatemanager.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getDetails: function() {
var details = [];
var business = this.getParameter('sysparm_business');
// Query the user record based on the sys_id
var userGR = new GlideRecord('sys_user');
userGR.addQuery('sys_id', business);
userGR.query();
if (userGR.next()) {
// Fetch the manager of the selected user
var manager = userGR.manager.getDisplayValue();
if (manager) {
// Add the manager's details to the response
var user = {};
user.manager = manager;
details.push(user);
}
}
return JSON.stringify(details);
},
type: 'Autopopulatemanager'
});
Try this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2024 06:45 AM
HI @Pratiksha ,
Thanks for the reply
I tried the above script include but it didnt worked...in client script the way im setting is wrong?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2024 07:45 AM
HI @Pratiksha ,
I figured it out in client script changed from g_form.setValue('common_vars_also_notify', unit[0].common_vars_also_notify); //set owner to g_form.setValue('common_vars_also_notify', unit[0].manager);
Now it is working fine when requested for is changed but when the form loads then the logged in user will be displayed in requested for field so in this case it is not working.
as client script is written only for onchange so can you please let me know how to make it work for onload.
It would be helpful if you provide the script for that