- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2023 03:49 AM
Hello Everyone,
We have the requirement where there are variables like Project start date and end date and also, Work package start date and end date on the main form. And, on the MRVS we have only Work package start date and End date.
Now, the work package start date and end date on the MRVS, should depend on the project start date and end date of the main form.
Is there any Possibilities to create OnChange Client script for Multiple Row Variable set depending on the main Catalog Item?
Can anyone please help with this?
Thanks and Regards,
Kruthika
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2023 06:18 AM
You can simply use g_service_catalog.parent.getValue... to get the main form variable values in an MRVS script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2023 10:22 AM
So your onChange script would look more like this now to only run for one specific Catalog Item:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var catitem = '';
if (this) { //Service Portal method
catitem = this.cat_g_form.getUniqueValue();
} else { //native UI method
catitem = parent.g_form.getUniqueValue();
}
if (catitem == '964185f78726a9100b25986d3fbb35c1') { //replace with the sysid of your Catalog Item
var ProjectStartDate = g_service_catalog.parent.getValue('value of project start date of catalog item');
var ProjectEndDate = g_service_catalog.parent.getValue(‘value of project end date of catalog item');
var WorkPackageStartDate = g_form.getValue(‘MRVS wrkpckgestart date’);
if (ProjectStartDate != '' && ProjectEndDate != '') {
if(!((WorkPackageStartDate >= ProjectStartDate) && (WorkPackageStartDate <= ProjectEndDate))) {
g_form.addErrorMessage("Please enter the dates in between Your Project Start Date and Project End Date i.e " +ProjectStartDate+" and "+ProjectEndDate);
g_form.clearValue((‘MRVS wrkpckgestart date’);
}
} else {
g_form.addErrorMessage('Please Enter Project Start Date and Project End Date');
g_form.clearValue((‘MRVS wrkpckgestart date’);
}
}
}
then create an onLoad Catalog Client Script that applies to the Catalog Item:
function onLoad() {
if (this) { // only needed for Service Portal
// make the g_form object for the parent item available from the MRVS window
this.cat_g_form = g_form;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2023 06:18 AM
You can simply use g_service_catalog.parent.getValue... to get the main form variable values in an MRVS script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2023 04:49 AM
Hello Brad,
Thank you so much for your support!!
I was struggling to solve this issue. Mainly to get the variables from the main form to the MRVS.
It really worked.
Thanks once again!
Regards,
Kruthika
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2023 05:36 AM
You are welcome!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2023 03:48 AM
Hello @Brad Bowman ,
We have the other requirement, where to make the Custom Variable as mandatory, OnChange of the other variable value. Below is the post created for the same. Would you be able to help on that?
https://www.servicenow.com/community/employee-center-forum/how-to-make-the-quot-custom-quot-variable...
Thanks in Advance!!
Regards,
Kruthika