- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2024 07:19 AM
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
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!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2024 01:09 PM
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);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2024 07:51 AM
Hi Samuel,
This onLoad Catalog Client Script that applies to the MRVS, not the Catalog Item, will do that when adding or editing a row:
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);
}
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2024 08:23 AM
Brad,
Thank you for your quick response tried it on my PDI, but it did not work like I really intended. I added the first two unchecked, the third one checked.
When I added the new row the default box still available for me to select, but if I select it then it will set to read-only, and still added as default. So now I have 2 default users (which isn't the goal)
Maybe there is something wrong with the logic?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2024 12:22 PM
It sounds like maybe you are running the script onChange instead of onLoad, or maybe you have an old script or UI policy in place from a previous attempt? When I execute your test steps, adding the new (4th) row opens the Add Row dialog with the Default checkbox read-only/grayed out.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2024 01:03 PM
Arghhh I see, but I can't reverse it aka edit the default and uncheck the checkbox since it's read-only