Glide Date Time -Catalog client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 09:08 AM
Is it valid to use GlideDateTime object and GlideDate for date field in catalog client script. I mean on client side?
Thanks,
Ruby
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 09:10 AM
Hi @Gousia Syed1,
The GlideDateTime object and GlideDate are APIs used in Server side scripts. To use in client side scripts you have to use it Script include s and get it using GlideAjax call.
If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers.
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2023 08:43 AM
Hi Sagar,
Thank you for the response. Can we use Date object like below in "onchange" client script.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var sd = new Date(g_form.getValue('start_date'));
var ed = new Date(g_form.getValue('end_date'));
If not, can you please explain in detail, it would be help ful.
Thanks,
Ruby
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2023 08:58 AM
Hi @Gousia Syed1,
Yes. you can easily get the current date time by using new Date() object in client scripts.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var sd = new Date(g_form.getValue('start_date'));
var ed = new Date(g_form.getValue('end_date'));
alert("sd: " + sd + " ed: " + ed);
}
Output:
sd: Thu Jun 10 2021 23:40:10 GMT+0530 (India Standard Time) ed: Sun Oct 10 2021 23:42:16 GMT+0530 (India Standard Time)
For reference take a look at this article: Client Side Dates in ServiceNow
If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers.
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2023 10:20 AM
Hi @Gousia Syed1,
Have you look into it? Let me know if you stuck and need any help.
If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers.
Thanks,
Sagar Pagar