Tip: How to use "List Collector" as an alternative to multiple checkboxes?
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 ?
- 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]
- Choose any cell in the Inactive column where value is false, right click on it, and select Show Matching
- Now hover the mouse over the filter in the Question Choices related list, right click on it, and select Copy query option
- 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=2b4ff94747101110a0f37258946d4351inactive=false - 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.
- Go to the Type Specifications section and select Question Choice [question_choice] table in the List table field.
- In the Reference qualifier field copy the query value from step 4 above
- 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.
- 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
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:
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
https://www.servicenow.com/community/now-platform-articles/tip-how-to-use-quot-list-collector-quot-as-an-alternative-to/ta-p/2323216