- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2024 09:18 AM
Hi,
I want to populate reference variable value from the table starts with A depands on choice value.
if choice data type variable value - abc, then reference variable value displays the list of users name starts with A.
if choice data type variable value - cde, then reference variable value displays the list of users name starts with B.
Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2024 01:41 AM - edited 06-28-2024 01:47 AM
Hi @BanuMahalakshmi ,
You can create a reference qualifier and script include,
In the below i created a field with type Select box and based on choice returning the Users,
Reference qualifier:
script include:
var getUserNames = Class.create();
getUserNames.prototype = {
initialize: function() {},
getNames: function(check) {
var arr = [];
var gr = new GlideRecord('sys_user');
if (check == 'choice1') //checking choice is abc
{
gr.addEncodedQuery('nameSTARTSWITHA');
} else if (check == 'choice2') //checking choice is def
{
gr.addEncodedQuery('nameSTARTSWITHb');
}
gr.query();
while (gr.next()) {
arr.push(gr.getValue('sys_id'));
}
return 'sys_idIN' + arr;
},
type: 'getUserNames'
};
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2024 01:41 AM - edited 06-28-2024 01:47 AM
Hi @BanuMahalakshmi ,
You can create a reference qualifier and script include,
In the below i created a field with type Select box and based on choice returning the Users,
Reference qualifier:
script include:
var getUserNames = Class.create();
getUserNames.prototype = {
initialize: function() {},
getNames: function(check) {
var arr = [];
var gr = new GlideRecord('sys_user');
if (check == 'choice1') //checking choice is abc
{
gr.addEncodedQuery('nameSTARTSWITHA');
} else if (check == 'choice2') //checking choice is def
{
gr.addEncodedQuery('nameSTARTSWITHb');
}
gr.query();
while (gr.next()) {
arr.push(gr.getValue('sys_id'));
}
return 'sys_idIN' + arr;
},
type: 'getUserNames'
};
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2024 02:15 AM
Thanks for marking my answer as helpful. If it helped you in any way please accept the solution so that it will be beneficial to the future readers with the same query.
Regards,
Swathi Sarang