Article #19 - How to show Catalog Variables on RITM Lists
Hi
Did you ever want to see a list of Requested Items including their variables in a List?
Catalog Variables are NOT stored as separate fields on the Requested item [sc_req_item] table but are stored in a separate table [item_option_new]. You cannot add those variables/fields using "Personalize List Layout" or "Configure/List Layout". Instead, you need to take some steps in the underlying tables to configure what you want to see.
In Scripts, you can dot-walk to the variables of RITM records inside GlideRecord objects with "gr.variables.".
Similarly, you can add Catalog Variables to the List of Requested Items.
Below, you can see the few steps to perform, to replay this function.
The result you will get by following this article
The result after following the steps below can be seen in the screenshot below. The right-most column in the "Default view" of the "Requested Item" table holds the Catalog Variable "How do you feel".
If the Requested Item (underlying Catalog Item) is using and filling this Variable, you can directly see the content/value of the variable for the given Requested Item in the List, instead of opening each RITM one-by-one to review the values of the variable.
Note:
because not all Catalog Items will utilize this Catalog Variable, a number of records will just show an empty field for that variable column. It may be a good idea to create separate Views for this use case and also filter on the RITMs, which leverages Catalog Items using that specific Catalog Variable.
Steps to reproduce
1) Create a Catalog Item with a variable.
In my example, I created a simple Catalog Item with just one Catalog Variable (see screenshot below).
2) Copy the SysID of the Catalog Variable to the Clipboard
Scroll down in the Form of the Catalog Item to the Related List of the Variables (1) and right-click the newly created Variable in the List (2) to select the menu entry "Copy sys_id" (3) - like shown in the screenshot below:
That copies the SysID, which we will need in one of the next steps.
3) Manually add a new Column to the List of the Requested Item table
Navigate to "> System UI > Lists" and filter for the "sc_re_item" table and the "View" for the "Default view" like shown in the screenshot below:
Open the record marked yellow in the screenshot above.
Make sure, that you selected the List for the "Requested Item" [sc_req_item] table (1) and for the "Default view" (2). Furthermore, make sure, the fields "Parent" (3), "User" (4), and "Relationship" (5) are empty.
Then Click on "New" (6) to add a new column to the List View definition.
In the form that opens, type "variables." in the field "Element" and then insert the SysID from the Clipboard, that we copied in the previous step. The form should look something like shown in the screenshot below.
Note:
Your SysID to be used will certainly be NOT like shown in the screenshot above (like "61e4c...."). So, make sure, that you use YOUR SysID from the Variable.
Click on "Submit" to Save the new Element for the List.
Your List configuration should now look similar to what is shown in the screenshot below:
4) Create a RITM on the new Catalog Item
Navigate to your new Catalog item and click the "Try it" button to use the Catalog Item "at run-time".
Enter some text into the variable field (1) and click on "Order Now" to create the RITM.
5) Review the Catalog Variable Column in the List of the Requested Item table
Type "sc_req_item.list" in the Application Navigator and hit or navigate to the list of Requested Items using the Application Navigator modules.
Make sure, that you are in the "Default view" (1) and also make sure, that you did NOT personalize this view (which you can see if there is NO small dot attached to the gear icon on the left side header line.
The new column for the Catalog Variable will be shown as the right-most column (2) in the List.
Records using that variable and having values for that variable will show their values directly in the List.
6) Review the List Layout
By clicking the gear icon to open the "Personalize List Columns" (1) popup, you can see the Variable column (2) added to the "Selected" fields in the slush bucket.
Note:
If you remove the Variable column ("How do you feel") from the "Selected" (2) List and Save the changes, you cannot return to the "Personalize List Columns" popup and add the column back to the list. The Column will not show up in the "Available" List (1) on the left side of the slush bucket.
To get the standard layout back, you need to click the "Reset to column defaults" (3) button, to bring the column back (which is pre-defined for the standard layout of the "Default View" List).
Note:
Furthermore, if you go to "Configure/List Layout" and remove the column from there, you need to start the steps from above to add the column back to the List View.
Wrap up
Adding Catalog Variables to Lists may become handy in different scenarios, but you should remember, that you create separate Views for this use case, so that the default views will not become "polluted" by these fields, which will not be filled for all RITM records.
Thank you for reading, and I hope you enjoyed this article.
Please provide your feedback on this article in the comments below.
If you like it, just mark this article as helpful and bookmark it using the "Bookmark" button above for later access.
Have fun and built something amazing on ServiceNow
Dirk
--------------------------------------------------------------------------------------------------------
If you like to also review my other articles on the ServiceNow Community, please have a look at the overview here:
NOTE: The content I provide here is based on my own experiences and does not necessarily represent my employer's views.
https://www.servicenow.com/community/now-platform-articles/article-19-how-to-show-catalog-variables-on-ritm-lists/ta-p/2323557