- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2024 08:09 AM - edited 08-12-2024 08:09 AM
Hello, I want to create an error message for a question. The question (date) variable is: what_is_the_expected_date_that_the_refresh_must_be_completed_by
The error message should say "Load release across partitions can only be completed on weekends." when users select thursday as a date AND say yes to variable load_release_across_partition.
This is a known problem with SN PRB1694977 as for some reason Thursdays don't work in the UI builder. Support told me ill need to script this one out. I am not too familiar with scripting, is someone able to help me with this?
If more background is needed please see my other post: Re: Can someone explain why trend by Thursday does... - Page 2 - ServiceNow Community
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2024 09:34 AM
Hi @Andrew Meza ,
Sharing the update set xml to you.
Catalog name is Weekday Catalog item.
After importing just hit the url,
/esc?id=sc_cat_item&sys_id=207ba938c3cc521017aeb61ed40131ee
I believe this will help you.
Regards,
Najmuddin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2024 12:09 PM
gs.addInfoMessage(day);
if(day == 1){
return true;
Now, by this logic, you should be able to select only one day. (Check which day is it.)
Next,
Change the line,
if(day == 1 || day == 2){ // Now check which day is actually day 2 is referring.
return true;
Continue like this until you get the right days.
Regards,
Najmuddin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2024 12:15 PM
Like this
Like this?
var checkWeekDay = Class.create();
checkWeekDay.prototype = Object.extendsObject(AbstractAjaxProcessor, {
weekDay: function() {
var day1 = this.getParameter('dateSelected')
var dayWithTime = day1 + " 12:00:00";
var gcdt = new GlideDateTime(dayWithTime); // fetch date
gs.print(gcdt);
var day = gcdt.getDayOfWeekLocalTime(); // return the local day number
gs.addInfoMessage(day);
if(day == 1){
return true
if (day == 7 || day == 6) {
// gs.addInfoMessage("weekend");
return true;
} else {
//gs.addInfoMessage("weekday");
return false;
}
},
type: 'checkWeekDay'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2024 12:22 PM - edited 08-13-2024 01:10 PM
Hi @Andrew Meza ,
Not like this.
[Removed] is my email address. Schedule a teams meeting at 1PM IST and I can help you in the call.
Regards,
Najmuddin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2024 12:47 PM
I think I got it! I apologize if this is what you have been telling me to do but you had days 7 & 6 in the script include. I changed them to 5 & 4 and its working!
var checkWeekDay = Class.create();
checkWeekDay.prototype = Object.extendsObject(AbstractAjaxProcessor, {
weekDay: function() {
var day1 = this.getParameter('dateSelected')
var dayWithTime = day1 + " 12:00:00";
var gcdt = new GlideDateTime(dayWithTime); // fetch date
gs.print(gcdt);
var day = gcdt.getDayOfWeekLocalTime(); // return the local day number
gs.print("Day:" + day);
if (day == 5 || day == 4) {
// gs.addInfoMessage("weekend");
return true;
} else {
//gs.addInfoMessage("weekday");
return false;
}
},
type: 'checkWeekDay'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2024 12:50 PM
Yeah, exactly.
May be the date format is different in my instance and yours.
I wanted you to check with all the days, trial and error method until you reached the right days.
Hope I had helped you.
Pleas mark as solution Accepted and helpful.
Regards,
Najmuddin.
