Subrahmanyam2
Giga Guru

Use Case / Requirement: Create 40 check boxes in a Service Catalog so that the requestors of can choose multiple items/applications for this they need access to.

Assumptions: Check boxes need to display in alphabetical order of display names

Developer Pain Point: Developer has to fill create each check box as a separate variable and it is a time consuming process.

How to use List Collector without creating custom tables ?

  1. Create a variable with Select box type and create all the choices in Question Choices related list from the Maintain Items module record form for the desired catalog item. Provide "Name, Value" field while specifying choices. [No need to populate "Order" field. Even if you fill it will not be helpful in our case]
  2. Choose any cell in the Inactive column where value is false, right click on it, and select Show Matching
  3. Now hover the mouse over the filter in the Question Choices related list, right click on it, and select Copy query option
    find_real_file.png
  4. A query similar to the one shown below will be copied to your clip board in step 3. Save it temporarily on a notepad if you like. 
    question=2b4ff94747101110a0f37258946d4351^inactive=false
  5. Scroll to the top of the form and change the Type of the variable to List Collector now. You will be able to observe the Type Specifications section tab will become mandatory. 
  6. Go to the Type Specifications section and select Question Choice [question_choice] table in the List table field.
  7. In the Reference qualifier field copy the query value from step 4 above
  8. Add no_filter as attribute in the Variable attributes field on the same section. This will make sure that we are removing the filter option that appears on the list collector field. End users need not view other fields on question choice table through filter.
  9. Not go to the catalog item configuration page and use Try it button to check how the list collector displays. It should appear as shown below for catalog_admin and admin users
    find_real_file.png
    Note: The list collector available choices will only display in the alphabetical order, even if you go to step 7 and append ^ORDERBYorder in the Reference qualifier to existing query, it will not have affect on how this list displays.

Make the catalog item available for normal users without the roles mentioned in point 9 above.

Impersonate any such user and try to open the service catalog form. You will see that the options will not show up.

Reason:

When you use List Collector variable, System evaluates ACL's to check if user has permissions to view the data in the table. The table we used here is question_choice. This ACL's on this table will not permit normal end users to view the data on this table.

When you use Select box type of variable, although it uses question_choice table, system will not evaluate ACL to render choices.

In order to start utilizing this approach and leverage this trick, we need to implement additional ACL on question choice table to make necessary data on it visible to non-admins.

Please create additional ACL as shown below:

find_real_file.png

find_real_file.png

Please find the code snippet in ACL below for you covenience.

answer = (function() {
    var qID = "",
        query, patt;
    try {
        query = current.getEncodedQuery();
        patt = /question=([0-9a-f]{32})/;
        qID = query.match(patt)[1];
    } catch (err) {
        qID = "";
    }
    if (qID != "")
        return (gs.isLoggedIn() && gs.isInteractive() && current.getValue("question") == qID);
    return false;
})();

The above ACL will make sure and not expose whole table to all users. It will make sure that the data is exposed on a need to view basis via this ACL.

 

Note: Please use your due diligence for any licensing implications/concerns. Kindly reach out to your account representative when in doubt.

 

Thanks and Regards,

Subrahmanyam

 

 

Comments
lholl
Tera Contributor

Anyone know if this incurs a licensing issue?

Vaibhav Sharma1
Tera Contributor

I also need to implement similar list collector in place of 20 check boxes, any inputs from anyone are highly valuable, can it be done without scripts?

Raviteja Kunal1
Tera Expert

I have tried same thing as mention but only first value is displayed other values are not displayed Screenshot below

 

RavitejaKunal1_0-1671019586770.png

 

Subrahmanyam2
Giga Guru

Hi Raviteja,

 

In your case it looks like the variable has max length limitation of around 40 characters due to which your second sys id of the choice is truncated.


And also based on your screenshot it looks like it is not a list collector variable. 

-

Subrahmanyam

 

Raviteja Kunal1
Tera Expert

Hi Subrahmanyam

 

The mentioned field is list type. Please see the screenshot below.

 

RavitejaKunal1_0-1671617849181.png

 

Justin Scheich
Tera Guru

Is there an update here? I also have the issue where the first value is shown but no subsequent values are shown. 

JustinScheich_0-1673035085144.png

 

Subrahmanyam2
Giga Guru

Hi Justin,
The issue in your case seems to be field length.
Looks like country is 40 characters in length, and glide list fields save comma separated sys_id values in the back end.
Due to field length, the first sys_id followed by comma and 7 more characters from next sys_id are getting saved in the field which sums up to 40 characters, and remaining are getting discarded.

You need to increase field length based on total or approximate max number of countries you would like to save in that field. 
You may use some formula like one mentioned below to decide the max length of glide list field.
(max countries you want to save in glide list) * 33 

Thanks and regards,

Subrahmanyam Satti

SimonSimon
Giga Sage

@Subrahmanyam2 Thank you for this write up! 🙌

EricG
Kilo Sage

@Subrahmanyam2  I like this idea and I'd like to use this on an Order Guide to include the Catalog Items when something is select.

EricG_0-1700672638631.png

I've create the Check Boxes for each Item - Set them as inactive.

 

Any thoughts on getting them to Show on the form or set the default value as true?

emmar00
Tera Contributor

Regarding the sorting of items (as mentioned in steps 1 and 9), this thread - https://www.servicenow.com/community/itsm-forum/change-the-sort-order-of-a-list-collector/m-p/684098 - indicates that you can use the Variable Attribute ref_ac_order_by to do sorting. I set an order for my Question Choices and was able to use ref_ac_order_by=order to make them display as I intended. Word to the wise: apparently this only works for Service Portal.

Tfnhodgi
Tera Contributor

Might be a dumb question but a vendor created this for me and I am having a hard time adding one new option to the list collector.

Justin Scheich
Tera Guru

Is the list collector referencing a table? 
Some screenshots would be helpful.

Tfnhodgi
Tera Contributor

Hi @Justin Scheich sorry for the late reply. 

This is the table. I added it to it.

sn_question.png

 

I added to the table but for some reason it is not showing up in my catalog item that uses the list collector.

Tfnhodgi_0-1719328861572.png

The other items that are blacked out are in the same table (and show) is there another place I need to add this to?

Justin Scheich
Tera Guru

@Tfnhodgi I see you have a reference qualifier listed there. 
The qualifier is most likely filtering out the new option you are trying to add. I would make sure you have the attributes needed to match the qualifier on the new choice you added. 

Tfnhodgi
Tera Contributor

@Justin Scheich can you please remind me where I could find where a reference qualifier lives? 

Version history
Last update:
‎07-01-2022 05:48 PM
Updated by: