How do I configure ServiceNow to add default checkboxes for each MRVs item

SamuelChang
Tera Contributor

I want to add a checkbox for each item, which only one can be selected (the other will gray out).

 

Here is what I have in mind

SamuelChang_0-1718720226411.png

 

If I select the first item, the second checkbox should be gray out vice versa. I've looked everywhere, but couldn't find any solution, if anyone have any guidance or alternatives I would be greatly appreciate it!

1 ACCEPTED SOLUTION

function onLoad() {
	var mrvs = g_service_catalog.parent.getValue('default_user_mrvs'); //internal MRVS name
	if (mrvs.length > 2) { //native UI returns [] for empty MRVS value whichc causes parsing error
		var obj = JSON.parse(mrvs);
		for (var i=0; i<obj.length; i++) { //loop through the existing MRVS rows
			if (obj[i].default_user == 'true') { //mrvs checkbox variable name
				g_form.setReadOnly('default_user', true);
			}
		}
	}
	if (g_form.getValue('default_user') == 'true') {
		g_form.setReadOnly('default_user', false);
	}
}

View solution in original post

8 REPLIES 8

function onLoad() {
	var mrvs = g_service_catalog.parent.getValue('default_user_mrvs'); //internal MRVS name
	if (mrvs.length > 2) { //native UI returns [] for empty MRVS value whichc causes parsing error
		var obj = JSON.parse(mrvs);
		for (var i=0; i<obj.length; i++) { //loop through the existing MRVS rows
			if (obj[i].default_user == 'true') { //mrvs checkbox variable name
				g_form.setReadOnly('default_user', true);
			}
		}
	}
	if (g_form.getValue('default_user') == 'true') {
		g_form.setReadOnly('default_user', false);
	}
}

This is it! Thank you Brad!!!

Quick question Brad, even though it's read only but when I select the Read-Only checkbox it still make it true on ServicePortal. Is there a known error?

SamuelChang_0-1718816348680.png

 

I am seeing the same in my Washingtondc patch 3 hotfix 1 PDI in Service Portal only.  If this isn't a known error, it should be.  Open a case with ServiceNow in the HI portal.