Make variable inside a MRVS mandatory onSubmit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2024 12:59 AM - edited 03-13-2024 01:00 AM
Hi Guys,
I have a requirement on a record producer tom make a variable inside a MRVS mandatory when the customer clicks submit.
Is this possible?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2024 01:09 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2024 01:18 AM
@Anirudh Pathak Thanks But I'm looking to make only 1 variable inside that MRVS mandatory.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2024 01:29 AM
follow thread it will be helpful
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0622896
Mark my answer as accepted solution and helpful if helps you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2024 02:21 AM
I think you can make that particular variable mandatory from the variable itself, and to prevent the form submisstion until it is filled, you can write a on submit client script. Below is the sample script you can use:
function onSubmit() {
var mrvs = g_form.getReference('mrvs_field'); // Replace 'mrvs_field' with the actual field name of your MRVS
if (mrvs) {
var rows = mrvs.getRows();
for (var i = 0; i < rows.length; i++) {
var row = rows[i];
var mandatoryFields = row.getMandatoryFields();
for (var j = 0; j < mandatoryFields.length; j++) {
var field = mandatoryFields[j];
if (!row.getValue(field.name)) {
alert("Please fill in all mandatory fields.");
return false; // Prevent form submission
}
}
}
}
return true; // Allow form submission if all mandatory fields are filled
}
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks