How to make cient script for empty mutli row vairbale
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2025 11:27 PM
These details in the form are necssary so when I make the filed Firewall details empty it should not generate any REq or it should not generated it's task number then .
Whenerver we click on Add button this kind of form is appears :-
when I make it as a empty in actual it should not generate any REQor TASK but in my client it's generating REQ weather it is filled or not
So here is my client script code :-
Please provide the suggestion on this ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2025 05:31 AM
Hello @aggarwaltan
function onSubmit() {
var firewallDetails = g_form.getValue('firewall_details');
if (!firewallDetails || firewallDetails === '[]') {
g_form.addErrorMessage("Please add at least one row to the multi-row variable set.");
return false;
}
try {
var rows = JSON.parse(firewallDetails);
if (!rows || rows.length === 0) {
g_form.addErrorMessage("Please add at least one row to the multi-row variable set.");
return false;
}
} catch (e) {
g_form.addErrorMessage("Error reading firewall details. Please ensure it's filled in properly.");
return false;
}
return true;
}
Hope that helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2025 05:51 AM
Simply make the MRVS mandatory so that it ensures at least 1 row is present
with this no scripting required
You can just make a Catalog UI Policy (on the Catalog Item) with a Catalog UI Policy Action to make the MRVS mandatory. In the UI Policy Action you can just select the MRVS.
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