- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2019 01:37 AM
Hello Experts, i have below requirement
How to display error message to user when he modfies the start date inside freezing period, here is the exact info
1. After the change is Approved, the freeze dates in the calender should be disabled only for the user to select and the alert message should be dispalyed stating that 'The Freeze dates are disabled for selection after the change is Approved. Reach out to Change_Managers for assisitance'.
2. The Change Managers would be able to modify it to freeze dates.
3. The users should still be able to modify it to other non-freeze dates once the change is Approved.
How can we achieve this
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2019 12:18 AM
Hello Nag,
In general, it is better to store the freeze dates in the database or use one of the existing SN feature something like blackout schedules and create a schedule with your freeze dates and compare your dates with this.
For now, you can use this below code as a quick fix.
Script Include
var Check_freeze_dates = Class.create();
Check_freeze_dates.prototype = Object.extendsObject(AbstractAjaxProcessor, {
check_freeze_dates:function() {
var date_to_check = this.getParameter('sysparm_date');
var gdt = new GlideDateTime(date_to_check);
freeze_date_start1=new GlideDateTime("2019-08-31 00:00:00");
freeze_date_end1=new GlideDateTime("2019-09-02 23:59:59");
freeze_date_start2=new GlideDateTime("2019-11-25 00:00:00");
freeze_date_end2=new GlideDateTime("2019-12-04 23:59:59");
freeze_date_start3=new GlideDateTime("2019-12-15 00:00:00");
freeze_date_end3=new GlideDateTime("2020-01-01 23:59:59");
if((gdt.after(freeze_date_start1)&&gdt.before(freeze_date_end1)) || (gdt.after(freeze_date_start2)&&gdt.before(freeze_date_end2)) || (gdt.after(freeze_date_start3)&&gdt.before(freeze_date_end3))) {
gs.log("Within the freezed date schedule "+date_to_check);
return 1;
} else {
gs.log("NOT in the freezed date schedule "+date_to_check);
return 0;
}
},
type: 'Check_freeze_dates'
});
Client Script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Call SI to check whether the date is in the freezed dates period
if(g_form.getValue("state") == 1) {
var ga = new GlideAjax('Check_freeze_dates');
ga.addParam('sysparm_name','check_freeze_dates');
ga.addParam('sysparm_date',newValue);
ga.getXML(callback);
function callback(response)
{
var answer = response.responseXML.documentElement.getAttribute("answer");
if(answer==1) {
g_form.addInfoMessage("Please select the date which is NOT in the freeze dates section");
g_form.setValue("start_date","");
}
}
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2019 01:42 AM
Hi,
you can use the JS function showFieldMsg() as per your need.
Refer to the following official documentation:
Hope this can help you.
If I have answered your question, please mark my response as correct and/or helpful so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.
Thank you
Cheers
Alberto

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2019 01:53 AM
HI,
So here you need couple of scripts
1) Client script which will check Freeze period and along with Approved status it will make the field readonly and editable.
2) Script Include to check Freeze period which will be called by above client script.
Thanks,
Ashutosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2019 03:12 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2019 11:35 PM
Hello Nag,
Write a client script which checks the status of the change on selection of dates. if its in approved, then call a SI which checks the selected dates with freeze dates and if they fall, then display the warning.