- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2018 04:50 AM
Hello,
I want to add an alert when the user selects a saturday or sunday from the datepicker.
But my simple alert('my msg') is not working in the catalog client script.
Could you please assist.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2018 12:11 AM
Hi Amruta,
Even the first line of alert is not working on form load?
Can you check whether this script is active.
For your requirement here is the full script
var date = g_form.getValue('<yourDateVariable>');
var dObj = new Date(date);
var selected_day = dObj.getDay();
if(selected_day == 6 || selected_day == 7){
alert('Date selected is Saturday or Sunday');
}
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2018 05:32 PM
Hi, are you able to post your client script?
You can try using g_form.addInfoMessage('message'); rather than your `alert`
Have you changed the "Run on" field on your client script to "Service Portal" or "All"?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2018 11:53 PM
Hi,
It will run. Check have you put alert in any condition. If you are running it on portal the select UI type to ALL. Instead of that you can also use g_form.addInfoMessage('my msg');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2018 04:42 AM
Hi Ankur,
Thanks for your reply. Its working fine
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2018 12:11 AM
Hi Amruta,
Even the first line of alert is not working on form load?
Can you check whether this script is active.
For your requirement here is the full script
var date = g_form.getValue('<yourDateVariable>');
var dObj = new Date(date);
var selected_day = dObj.getDay();
if(selected_day == 6 || selected_day == 7){
alert('Date selected is Saturday or Sunday');
}
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader