- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 07-23-2020 03:13 AM
We had a requirement of ordering multiple items using service catalog with some variables like Item Name, Quantity etc. This was usually handled in a way by creating multiple catalog items and adding them to the cart. But, in this scenario, our requirement was to achieve it in a single catalog item. Luckily, ServiceNow has released a new feature "Multi Row Variable Set (MRVS) with the London release and we are currently in London release and hence, we thought to take this approach. Initially, we hadn't faced any issues and later on we had few challenges in validating the duplicates etc,. and though it took us some time to research, finally we were able to achieve the requirement. Hence, though of sharing some of the things here so that it may be helpful for the others.
1. Making MRVS Mandatory: This is pretty simple, you would create an UI Policy on the Catalog Item (Not on Variable Set) and in the UI Policy Action, you would need to select the MRVS Name in "Variable name" and select "Mandatory" as TRUE.
2. Validating the Duplicates:
We had an reference variable (Item name) and the string variable (quantity) and before the user can order the catalog item, we would need to find the duplicates in the selections and abort the form submission if the duplicates are found which means the same item cannot be selected again. You can have the OnSubmit() client script on the Catalog Item (Not on Variable Set).
We were able to get the MRVS data in JSON format in the client script but the issue here is that it returns the sys_id of the variables instead of the variable name. Hence, first we need to replace the sys_id with the variable name.
function onSubmit() { var getData = g_form.getValue('enter your mrvs name here'); //MultiRow Variable Set Name getData= getData.toString().replace(/sys_id_of_the_variable/g, 'varibale_name'); //'variable_name' - Variable in MRVS. var mrvData = JSON.parse(getData); for (var i = 0; i < mrvData.length; i++) { findDuplicateEntries(items); if (result.length > 0) {
|
Finally, we were able to validate the duplicates and restrict the form submission if the duplicates were found.
3. Service Portal Issue
During our testing phase, we have observed that the the Multi Row Variables were not getting copied / displayed on the RITM Variable editor, when the catalog item is submitted from the Service Portal, which was an show stopper. The fix for this issue is to replace the widget "SC Catalog Item Deprecated" with the "SC Catalog Item" which is the latest version and post this change, it has displayed all the Multi Row Variables in the RITM Variable Editor.
- 8,492 Views