Need help in Business Rule Scripting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2024 09:37 AM - edited 05-24-2024 09:39 AM
I have written a Business Rule to create an Announcement when Incident priority changes to P1. Everything is working fine except one field in Announcements table. There's a field called From in the record but its setting date and time as 2 hours from current date and time
Inc updated at 24-05-2024 18:25:43 and From is set to 24-05-2024 20:25:43, which should be 24-05-2024 18:25:43
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2024 09:58 AM
You can select whether you want time in UTC/GMT or you want time in user time zone as they can be different
To get time you see on incident form, use Local time code as shown below
var gdt = new GlideDateTime();
gs.info(' 1. UTC Time: ' + gdt.getValue());
gs.info('2. Local Time in user time zone: ' + gdt.getDisplayValue());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2024 09:58 AM
Hi @Admin7267 ,
You can set directly the value of the field
Sample code:
var date=new GlideDateTime();
gr.<Your field backend name>=date.
Regards
Vengadesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2024 10:19 AM
Hi @Admin7267 ,
Please try to use below script
var dateTime = new GlideDateTime();
gs.info('Check' + dateTime.getDisplayValue());
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak