- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2023 12:13 PM
Good day,
Im trying to set a Variable in a MRVS mandatory. i know the basic ways to do this but the problem im having is there is a requirement to make it that way when a checkbox is Check(true). the check box lives in a Variable set.
so i created a Catalog Script and it goes as following
Applies to (catalog Item) Type (onChange)
Catalog Items (Banking)
Variable name (v_needed_checkbox)
I have it to apply to the Catalog Item, Requested Item and Task item Views
This is the code i wrote but im going in the wrong direction or something is wrong
function onChange (control, oldValue, newValue, isLoading)
if (isLoading || newValue == '') {
}
if (g_form.getValue('v_needed_checkbox' == true)) { //Variable set (card collection)
g_form.setMandatory('business_bank_card.approving_user_id' , true);{ // Multi Row Variable set (approval info)
}
}
can you provide your throughts on the best way to make this variable Manadatory
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2023 12:51 PM
Hi Walter,
In this case, you'll want to make the variable mandatory when you are adding or editing a row, after checking the value of the checkbox variable. Note that this won't enforce the mandatory variable within the MRVS for rows that are added before the box is checked, but you can create a separate onSubmit script to validate that all rows have a value for this variable, if this scenario is likely to occur.
So you'll want an onLoad Catalog Client Script that applies to the MRVS, not the Catalog Item. Your script would look like this:
function onLoad() {
if (g_service_catalog.parent.getValue('v_needed_checkbox') == true) { //if this doesn't work, try 'true'
g_form.setMandatory('approving_user_id', true); //mrvs variable name
}
}
I'm assuming in your example 'business_bank_card' is the name of the MRVS and 'approving_user_id' is the name of the MRVS variable?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2023 12:26 PM
Please confirm, if this client script defined at multi-row set level of at catalog level.
I think, when we click on ADD button for adding items in multi-row then multi-row form should check this "v_needed_checkbox" condition, so this client script should part of multi-row definition.
-Thanks,
AshishKMishra
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2023 12:51 PM
Hi Walter,
In this case, you'll want to make the variable mandatory when you are adding or editing a row, after checking the value of the checkbox variable. Note that this won't enforce the mandatory variable within the MRVS for rows that are added before the box is checked, but you can create a separate onSubmit script to validate that all rows have a value for this variable, if this scenario is likely to occur.
So you'll want an onLoad Catalog Client Script that applies to the MRVS, not the Catalog Item. Your script would look like this:
function onLoad() {
if (g_service_catalog.parent.getValue('v_needed_checkbox') == true) { //if this doesn't work, try 'true'
g_form.setMandatory('approving_user_id', true); //mrvs variable name
}
}
I'm assuming in your example 'business_bank_card' is the name of the MRVS and 'approving_user_id' is the name of the MRVS variable?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 06:11 AM
Brad,
Thank you for your solution. it worked perfectly. I did have to add the ('true') for the "if" portion of the script.
function onLoad() { if (g_service_catalog.parent.getValue('v_needed_checkbox') == true) { //if this doesn't work, try 'true' g_form.setMandatory('approving_user_id', true); //mrvs variable name } }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 06:17 AM