- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2024 05:20 AM
Hi Experts,
My requirement is in "Multi row variable set, the second record of the 'start date' it should not the less than of 'end date' of the first record, I written On_change Catalog client scripts in MRTS but it not working as expected ,please any one can suggest or give inputs ,how can i achieve this ,
for reference see the attachment :
in below image the first record End date is 2024-08-01 , but in second record the Start date should not select the less than of @2024-08-01 date .
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2024 06:19 AM - edited 07-24-2024 06:21 AM
If the use case is truly limited to 2 rows in the MRVS, this script onChange of the Start Date MRVS variable will work:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var mrvs = g_service_catalog.parent.getValue('mrvs1'); //replace with your mrvs internal name
if (mrvs.length>2) { //native UI empty MRVS = '[]' which causes a parsing error
var obj = JSON.parse(mrvs);
//prevent end date less than start date of first row
if (newValue < obj[0].end_date_mrvs) { //replace with your MRVS variable name
alert('Start Date cannot be early than previous row End Date.');
g_form.clearValue('start_date_mrvs'); //replace with your MRVS variable name
}
}
}
If there's a possibility that more rows will be added, and the requirement is that the new row start date should never be before the previous row end date, it would look more like this:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var mrvs = g_service_catalog.parent.getValue('mrvs1'); //replace with your mrvs internal name
if (mrvs.length>2) { //native UI empty MRVS = '[]' which causes a parsing error
var obj = JSON.parse(mrvs);
//prevent end date less than start date of previous record
if (newValue < obj[obj.length-1].end_date_mrvs) { //replace with your MRVS variable name
alert('Start Date cannot be early than previous row End Date.');
g_form.clearValue('start_date_mrvs'); //replace with your MRVS variable name
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2024 06:19 AM - edited 07-24-2024 06:21 AM
If the use case is truly limited to 2 rows in the MRVS, this script onChange of the Start Date MRVS variable will work:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var mrvs = g_service_catalog.parent.getValue('mrvs1'); //replace with your mrvs internal name
if (mrvs.length>2) { //native UI empty MRVS = '[]' which causes a parsing error
var obj = JSON.parse(mrvs);
//prevent end date less than start date of first row
if (newValue < obj[0].end_date_mrvs) { //replace with your MRVS variable name
alert('Start Date cannot be early than previous row End Date.');
g_form.clearValue('start_date_mrvs'); //replace with your MRVS variable name
}
}
}
If there's a possibility that more rows will be added, and the requirement is that the new row start date should never be before the previous row end date, it would look more like this:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var mrvs = g_service_catalog.parent.getValue('mrvs1'); //replace with your mrvs internal name
if (mrvs.length>2) { //native UI empty MRVS = '[]' which causes a parsing error
var obj = JSON.parse(mrvs);
//prevent end date less than start date of previous record
if (newValue < obj[obj.length-1].end_date_mrvs) { //replace with your MRVS variable name
alert('Start Date cannot be early than previous row End Date.');
g_form.clearValue('start_date_mrvs'); //replace with your MRVS variable name
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2024 06:49 AM
Thanks Brad Bowman, its fixed my issue.