Prevent catalog submission based on date field in text box (string field) in MRV
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2022 07:40 PM - edited 11-17-2022 07:45 PM
Hi,
I am populating date field in string field in MRV and want to prevent submitting the form if any of the date is more than 365 days with today's date and if it falls less than 365 days then form should be submitted. I have written onsubmit client script but Its not checking for all date fields (in rows)
function onSubmit() {
var today = new Date();
//today.setHours(0,0,0,0);
var startDTe = g_form.getValue('course_completed_date');
//alert(startDTe);
var startDateNum = getDateFromFormat(startDTe, g_user_date_format);
var coursedate = today - startDateNum;
alert(coursedate);
var dayDifference = coursedate / (1000 * 60 * 60 * 24);
// alert(dayDifference);
if (dayDifference > 365) {
return false;
}
return true;
}
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2022 01:00 PM
Did you try using UI policy?
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2022 01:03 PM
No, date field in MRVS is string field. Can we use UI policy with date as string field? And abort submitting the form if any of the date is more than 365 days?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2022 01:14 PM
Hi,
Is there any specific need to remain date as string?
Cannot we provide user the opportunity to select the date.
How are you ensuring the correct date/format is entered by user?
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2022 01:05 PM - edited 11-21-2022 01:07 PM
Hi @reddy8055
I think you can use a simple UI policy.
Example-
UI Policy
Please mark the answer as correct, If I answered your query. It will be helpful for others who are looking for similar questions.
Regards
Saurabh
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2023 06:22 AM
Agree to this proposal.
We implemented this also via UI Policy
- we needed to control max 365 days in the future is selected, no more
- we needed to control that end date is not less than start date
All done with 2 separate UI policies
/Petr