how to validate multirow variable date filed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2025 11:23 AM
Hi Everyone
I have multirow variable date filed, how to validate date filed with date value
as shown below first user enter 25/07/25 then second time they enter 23/07/25
my requirement is it should not allow previous date

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2025 12:15 PM
To validate a Date field inside a Multi-Row Variable Set (MRVS) in a catalog item, you’ll need to use Catalog Client Scripts in combination with g_form.getControl() and a loop over the MRVS rows.
✅ 1. Use a Catalog Client Script (onLoad or onSubmit)
Here’s how you can loop through rows and validate a date field:
function onSubmit() { var isValid = true; var rows = g_form.getMultipleRows(); // all rows of MRVS for (var i = 0; i < rows.length; i++) { var dateVal = rows[i].variable_name; // replace with your date field's variable name if (new Date(dateVal) < new Date()) { isValid = false; g_form.showFieldMsg('multi_row_variable_set', 'Date must be in the future', 'error'); break; } } return isValid; }
✅ 2.
Alternative: Use g_form.getValue() on MRVS Scoped Name
If the MRVS is named my_mrvs, and your date variable is my_date, access like:
var allRows = g_form.getValue('my_mrvs');
…but this returns a stringified object. You’ll need to parse the value if accessed this way — not recommended unless you’re comfortable with serialized MRVS data.
🔒 Important:
MRVS fields are tricky — client scripts must be global (Type: Catalog Client Script) and set for “Applies on Requested Item”.
Server-side validation can also be done via Catalog Item Validator Script for extra enforcement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2025 03:14 AM
Try adding Catalog Client script applies to Variable Set.
Let me know if you need the code for validation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2025 03:31 AM
previous means which one? the 1st row?
you can use onSubmit catalog client script which applies on catalog item
Then get the MRVS JSON, iterate and then compare the dates and if any date is previous than date in 1st row then throw error.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader