Controlling Modal Reopening in MRVS

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2025 02:21 PM
I have a requirement where, when an MRVS (Multi-Row Variable Set) is opened and the user clicks "Add", the modal needs to be reopened to allow filling in the next row. When clicking "Cancel", the modal should be closed and cannot be reopened.
The issue is that I noticed that if I open the modal for editing and save the record, the modal gets reopened to add a new row.
I managed to solve it with the following code:
var actionButton = document.querySelector('.btn.btn-primary.dialog-buttons');
//If the button label is "Save", the modal doesn't need to be reopened
if (actionButton.textContent.toLowerCase().indexOf('save') != -1)
return true;
//If the button label is "Add", the modal is closed and must be reopened
else
TableVariableService.createTableRow('8184fbcb1b3470509e68766f034bcb43', 'e4c4554d1b7434109e68766f034bcbb8');
}
But I would like to check if there's a way to do this without using querySelector?
P.S.: This code is running from the desktop.
Thanks in advance,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2025 04:38 AM
your code uses DOM manipulation which is not a best practice and it won't work on portal.
I don't think any other way
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