The CreatorCon Call for Content is officially open! Get started here.

Service Portal (Catalog Item) List Collector field - getDisplayValue / getDisplayBox does not work

MWright1
Giga Guru

Hi all,

 

I have seen a bunch of posts regarding this.  However have not found any solution suitable to my needs.

 

Here is the situation:

1. I have a List Collector item in my Catalog item (accessed through the Service Portal).  This item is a list of groups the user belongs to.

2. I need to get the name of the items to remove the groups that contain a certain phrase.  For example:  remove the user's association with the groups that contains the words "technician" in the group name.

3. So I need to get the names of the groups the user belongs to; not the id.

 

So i have tried the following to get the display name of this field - neither worked:

val = g_form.getDisplayValue ('user_groups'); 
val = g_form.getDisplayBox ('user_groups');
 
This worked but gives me the id - not what I need:
val = g_form.getValue ('user_groups');
 

Any assistance would be highly appreciated.

 

Thanks,

M

 

1 ACCEPTED SOLUTION

Since you've already made the trip to the server to get the group sys_ids, you could also get the group names at the same time to use for the name test and populating both list collectors with sys_ids.

View solution in original post

6 REPLIES 6

Brad Bowman
Kilo Patron
Kilo Patron

You'll need to send the value of the list collector variable to a Script Include via GlideAjax.  The Script Include will execute a GlideRecord on the list table with the query condition ('sys_id', 'IN', sysids) where sysids is a script variable assigned to the this.getParameter for the list collector value from the client script.  For each record returned, either push the group.name (if the list field is sys_user_grmember) or name (if the list field is sys_user_group) to an array or test it against the certain phrase, depending on what you're trying to do.  If you want the list collector variable value updated to not include any groups whose name contains a certain phrase, if the name test passes, push the value of the sys_id to an array, otherwise don't, then return the joined array and set the value of the list collector variable to the response from the SI.  Give the scripts a shot and post them using the insert code icone </> if you get stuck.

Thanks.  I was hoping for a more elegant way to do this.

M

Do you need something to happen on the initial request form, as/after records are selected, or when viewing the RITM and the list collector variable is already populated, or after submitting the initial request, before the RITM is viewed?

The flow is this:

1. Service Portal Form is loaded - user select an employee (a Reference variable)

2. Client script pulls in all the groups the employee belongs to (I got to this point - I pulled all the sys_id of the groups this employee belongs to)

3. On the form there is a request to remove from - say remove from "Technician" or it could be "Manager".  

4. So I now need to loop through all the groups this employee belongs to and identify which ones start with "Technician" and add them to the "Remove group from" (another List Collector variable) .

 

Thanks,

M