- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2021 05:07 AM
HI,
We have a requirement on Multirow variable set, when ever user clicks on add it should copy previous row variable to new row.
Can some one suggest how to achieve this
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2021 06:04 AM
Hi Kri,
First you'll need an onLoad Catalog Client Script running on the Catalog Item itself, not within the MRVS. Set the UI Type to All.
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;
}
}
Now within the MRVS we can create an onLoad Catalog Client Script within the MRVS, also with the UI Type = All.
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('test_1', obj[obj.length-1].test_1);//name of the first MRVS variable to autopopulate
g_form.setValue('test_2', obj[obj.length-1].test_2);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2021 06:04 AM
Hi Kri,
First you'll need an onLoad Catalog Client Script running on the Catalog Item itself, not within the MRVS. Set the UI Type to All.
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;
}
}
Now within the MRVS we can create an onLoad Catalog Client Script within the MRVS, also with the UI Type = All.
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('test_1', obj[obj.length-1].test_1);//name of the first MRVS variable to autopopulate
g_form.setValue('test_2', obj[obj.length-1].test_2);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2021 06:53 AM
Thanks Brad, It worked
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2021 06:59 AM
You are welcome.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2023 06:42 AM
It is working..