Variable option from MRVS should make a variable on the form mandatory
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2024 03:33 AM - edited 11-11-2024 03:35 AM
Hi,
I have a variable Record Type in MRVS which is a selectbox. When we select an option (Other) in this variable, it should make a variable (Add Attachment) on the form mandatory. Is it possible? If yes, how is it done? Kindly help.
Regards
Suman P.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2024 03:59 AM - edited 11-11-2024 04:01 AM
Hi @Community Alums ,
The tough part is to get the MRVS data into the form , can you try and see just g_form.getValue('MRVS VARIABLE SET NAME');. This should return you the values in a JSON format post that can you set your field mandatory based on the value. The tricky part is at which event you will write this mandatory check. You can try writing an onSubmit Client Script on your MRVS and then try to set the mandatory check on your form by accessing the MRVS values after collecting it using as stated in the above statement.
To access values and how to process it you can refer below thread:
Please mark correct/helpful if my response helped you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2024 04:44 AM
You can do this with an onChange or onSubmit Catalog Client Script that Applies to the MRVS:
function onSubmit() {
if (g_form.getValue('v_record_type') == 'other') { //MRVS variable name and choice value
if (this) { //Service Portal method
this.cat_g_form.setMandatory('v_attachment', true); //catalog item variable name
} else { //native UI method
parent.g_form.setMandatory('v_attachment', true); //catalog item variable name
}
}
}
If you are using Service Portal, this onLoad Catalog Client Script that applies to the Catalog Item is also required:
function onLoad() {
if (this) {//we only need to do this for Service Portal
//We need to make the g_form object for the parent item available from the MRVS window
this.cat_g_form = g_form;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2024 04:55 AM
Hi @Brad Bowman ,
I have used this, but it is not working. It is directly submitting the form. It is a catalog item.
function onSubmit() {
if (g_form.getValue('record_type') == 'noinfo') //MRVS variable name and choice value
{
g_form.setMandatory('add_attachments', true); //catalog item variable name
}
}
Regards
Suman P.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2024 05:25 AM
To use this approach you would have to first get the value of the MRVS, then loop through the results to see if any of the record_type variables have the value of noinfo in any row. The problem with this approach is that you are only then setting the attachment variable to mandatory, so it's not as user-friendly as giving them the chance to notice that it's already mandatory before submitting the form.