- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2025 03:23 AM
Hi
When Demand state changes to complete , project record should be created. I am trying this through Business Rule.
When project record is created , Approved End Date field should default to current date with 5pm EST.
Basically I am looking for the script, how we can set the Approved End Date field to current date with 5pm EST before the project record is inserted.
Regards
Akshatha
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2025 03:32 AM - edited 03-04-2025 03:45 AM
Hi @Akshata5
What's your instances default time zone? If it's EST then you can refer the below script.
var date = new GlideDate().getDisplayValue();
var date_str = date + " 17:00:00";
var final_date = new GlideDateTime(date_str);
gs.print(final_date);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2025 03:32 AM - edited 03-04-2025 03:45 AM
Hi @Akshata5
What's your instances default time zone? If it's EST then you can refer the below script.
var date = new GlideDate().getDisplayValue();
var date_str = date + " 17:00:00";
var final_date = new GlideDateTime(date_str);
gs.print(final_date);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2025 03:45 AM
Thank you so much. It worked like a charm.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2025 03:47 AM
Glad to hear.
Thanks for accepting the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2025 03:52 AM
check my blog
use this sample script as well in before insert/update business rule
var strConvertedDateTime = new GlideScheduleDateTime(new GlideDateTime()).convertTimeZone("UTC", "EST");
var gdtConvertedDateTime = new GlideDateTime(strConvertedDateTime);
gs.info('GMT time' + new GlideDateTime());
gs.info("Converted Time to EST: "+gdtConvertedDateTime);
current.setDisplayValue('dateTimeField', gdtConvertedDateTime);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader