- 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-24-2022 11:06 AM
what if I'd like it to renumber when they delete rows or add new ones at the end during fulfillment? can I just copy this as an onChange?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2022 05:51 AM
There's not a client/form way to identify/trigger a change in the contents of an MRVS. What you can do is run a client script onSubmit of the request form/ritm/task that retrieves the MRVS (as JSON) then iterates through each row, resetting the value of this variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2022 05:51 PM
Solution can be found here:
