Controlling Modal Reopening in MRVS

Flavio Tiezzi
Kilo Sage

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,

 

1 REPLY 1

Ankur Bawiskar
Tera Patron
Tera Patron

@Flavio Tiezzi 

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.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader