- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2020 03:59 PM
I'm using a Lookup Select Box variable for a 2nd approval in my catalog item. This variable is referencing the sys_user_group table and I have a reference qualifier specifying the 3 groups to be referenced for the drop-down selection in the variable on the form.
In order for the workflow to stop (instead of automatically skip) at this "Approval - Group" activity, the lookup value field for the variable has to be the Sys_ID instead of Name. For the Lookup Select Box field on the form, I need it to display the group names NOT the Sys_IDs.
I think the best way to achieve this is to use a Catalog Client Script but I'm unsure of how it should be written. Can someone help me with this??
Thanks,
Brandon
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2020 09:59 PM
Instead of using Lookup Select Box, how about using Reference type? Reference type will enable to display Name field and still use sys_id.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2020 09:24 AM
If you don't want to use reference type instead of Lookup Select Box, another option is to use Select Box and dynamically fill it with Name with sys_id as the value.
This will require writing a Script Include to query the database table and a Client UI script to dynamically fill the Select Box.
I haven't tested the code but something like below:
Client Script:
function onLoad() {
var ga = new GlideAjax('usergroup');
ga.addParam('sysparm_name', 'getUserGroups');
ga.getXML(fillUserGroup);
function filluserGroup(response) {
if (response) {
g_form.clearOptions('user_group');
var user_group = response.evalJSON();
g_form.addOption('user_group', user_group.name, user_group.sys_id);
}
}
}
Script Include:
var usergroup = Class.create();
usergroup.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getUserGroups: function() {
var user_group_array = [];
var svrObj = new GlideRecord('sys_user_group');
svrObj.addEncodedQuery('<copy refreence qualifier here>');
svrObj.query();
if (svrObj.next()) {
user_group_array.push({"name": svrObj.name, "sys_id": svrObj.sys_id});
}
JSON.stringify(user_group_array);
},
type: 'usergroup'
});

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2022 04:38 AM