- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2022 03:09 AM
Hi Expert,
How to increase row number automatically when we click on the "Add" UI action on the MRVS? is it possible?
In the below screenshot, i added the row(1,2) manually.
Thanks,
Antony
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2022 04:15 AM
Hi Antony,
These scripts will get you there, but you could be welcoming trouble due to the ability to edit and delete rows - so user actions could cause the row numbers to appear out of order. You can make this variable read-only and resort the MRVS or re-number the Row variable onSubmit if that's an issue.
First, if you're using Service Portal, you'll need an onLoad Catalog Client Script that Applies to the Catalog Item, not within the MRVS.
function onLoad() {
if (this) {//we only need to do this for Service Portal
//We need to make the g_form object for the parent item available from the MRVS window
this.cat_g_form = g_form;
}
}
Next, an onLoad Catalog Client Script that Applies to the Variable Set:
function onLoad() {
var mrvs = '';
if (this) { //Service Portal method
mrvs = this.cat_g_form.getValue('mrvs1');//internal name of your MRVS
}
else { //native UI method
mrvs = parent.g_form.getValue('mrvs1');
}
if (mrvs.length > 2) { //native UI returns [] for empty MRVS value
var obj = JSON.parse(mrvs);
g_form.setValue('v_row', parseInt(obj[obj.length-1].v_row) + 1); //your variable name
}
else {
g_form.setValue('v_row', '1');
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2022 03:57 AM
can you elaborate a bit more ? what are you looking for exactly?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2022 04:10 AM
Hi Ravi,
Thanks for your response. The requirement is when i click on the "Add" button to add the row into MRVS, the below page will popup
Then the row field should be auto populate as 1. When i add the second row in the MRVS, the row field should auto populate to 2. likewise the row field value has to auto increase whenever we add a new row into the MRVS.
Thanks,
Antony
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2022 04:15 AM
Hi Antony,
These scripts will get you there, but you could be welcoming trouble due to the ability to edit and delete rows - so user actions could cause the row numbers to appear out of order. You can make this variable read-only and resort the MRVS or re-number the Row variable onSubmit if that's an issue.
First, if you're using Service Portal, you'll need an onLoad Catalog Client Script that Applies to the Catalog Item, not within the MRVS.
function onLoad() {
if (this) {//we only need to do this for Service Portal
//We need to make the g_form object for the parent item available from the MRVS window
this.cat_g_form = g_form;
}
}
Next, an onLoad Catalog Client Script that Applies to the Variable Set:
function onLoad() {
var mrvs = '';
if (this) { //Service Portal method
mrvs = this.cat_g_form.getValue('mrvs1');//internal name of your MRVS
}
else { //native UI method
mrvs = parent.g_form.getValue('mrvs1');
}
if (mrvs.length > 2) { //native UI returns [] for empty MRVS value
var obj = JSON.parse(mrvs);
g_form.setValue('v_row', parseInt(obj[obj.length-1].v_row) + 1); //your variable name
}
else {
g_form.setValue('v_row', '1');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2022 04:52 AM
Hi Brad,
It worked fine. And yes its not re-numbering when we delete the row in between. I will talk to the client for the re-numbering part.
Thanks,
Antony