Auto Populate all the users when site code is selected
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2024 07:14 AM
I have a requirement in which when I select Site code in catlog item which is reference to cmn_location then all the associated user related to that site code should be populated in such a way that, we can select multiple user through check box.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2024 10:35 AM
@NirajK4122 Assuming you have a dependent field to display the users for selection based on "Site" code.
You can add reference qualifier as below on field which lists the users based on location.
Table : User [sys_user]
javascript: 'location='+current.variables.<your field>
Note: If reference field, try to pass the sys_id.
Please mark this as helpful and accept it as a solution if this resolves your query.
Thanks,
Sujatha V.M.
Sujatha V.M.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2024 10:47 AM
Hi @NirajK4122
Can you try writing client script with following code-
function onChangeSiteCode() {
var siteCode = g_form.getValue('site_code'); // Get the selected Site Code value
var multiSelectField = 'associated_users'; // Change this to the actual name of your multi-select field
g_form.clearOptions(multiSelectField);
var userGr = new GlideRecord('sys_user');
userGr.addQuery('site_code', siteCode);
userGr.query();
while (userGr.next()) {
var userSysID = userGr.getUniqueValue();
var userName = userGr.getValue('name'); // Change this to the appropriate field displaying user name
g_form.addOption(multiSelectField, userSysID, userName);
}
}