How to tell if I'm adding a new row or editing a row in a multi-row variable set (MRVS) with g_form

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 07:28 AM
Is there any way using g_form or any other client side object to tell when a MRVS row is opened either by using the pencil or clicking add? I notice the header at the top is different.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 08:52 AM
I'd like to see if others have a solution based on the behind the scenes inner-workings, but this approach backs into it.
An onLoad Catalog Client Script that applies to the MRVS will run when adding or editing a row. If any variables contain a value, then you must be editing the row. This would be more certain if you have at least one mandatory variable, to prevent a false positive if some yahoo adds an empty row, but you get the idea.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 08:54 AM
Thanks Brad,
At this point I've solved the problem by restructuring my UI policies.
What you are suggesting could work, but it wouldn't be a very elegant solution. Curious if anyone knows of another way.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2023 01:02 PM
If you're up for some verboten DOM manipulation, you can create a script like this that applies to the Variable Set. The else if is overkill as there are only two options, but it shows the attibute of both buttons. Note that this will not work in Service Portal or Employee Center.
function onLoad() {
var btn = this.document.getElementsByClassName("btn btn-primary dialog-buttons");
if (btn[0].innerText == 'Add') {
alert('You are adding a row');
} else if (btn[0].innerText == 'Save') {
alert('You are editing a row');
}
}