- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2024 07:28 AM
Hi @Atchutaram
Regards
Dr Atul G. - Learn N Grow Together ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
******************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2024 08:01 AM
Hi @Dr Atul - LNG I am writing this script on on change client script. This is working but when we save the form or submit the valid to is still changing and getting the form saved.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var validityField = 'valid_to';
var onYearValidity = new Date(new Date().setFullYear(new Date().getFullYear() + 1));
var newValidity = new Date(newValue);
if(newValidity > onYearValidity) {
// g_form.clearValue(validityField);
g_form.showErrorBox(validityField,'Valid to date must be within a year from today');
} else {
g_form.hideErrorBox(validityField);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2024 08:12 AM
Hi @Atchutaram
This is my weak area :(. I am not a developer.
@Jaspal Singh @Community Alums any help here.
Regards
Dr Atul G. - Learn N Grow Together ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
******************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2024 08:20 AM
Thank you @Dr Atul - LNG for your assistance, i am also posting this as one more question with code. Thank you very much for extending the help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2024 08:47 AM
@Dr Atul - LNG thanks 👍
Hi @Atchutaram ,
There are 2 dates here one is article created date and another one is today's date so which of this 2 dates do you want to limit it to 1year ?
If it's today's date then you can simply do it with UI policy using relative filter. If it's created (or published date) you have to use Client script and check if the date selected falls within the 365days since publish or created.
I hope this helps...