Set last day of month and time 23:59:00
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2024 01:39 AM
Hi Team,
we have one field called due date in which we have to populate the last day of the month from the pre-hire field and the time should be 23:59:00 which should according to America/new_york time zone
suppose in the pri-hire field we have (10/02/2024) so in the due date field I want populate 29/02/2024 23:59:00 according America/new_york
I am not getting logic with script.
I am working on scoped application.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2024 02:37 AM - edited 02-19-2024 02:58 AM
Hi @lucky24,
Working with dates and times can always be fun. You need to do something along the lines of the below.
Can you confirm if this to happen on change - when the pre-hire field is populated for example?
To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Helpful.
Thanks, Robbie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2024 06:47 AM - edited 02-19-2024 06:49 AM
Hi Robbie,
Thanks for your response, I tried with business rules and written code but it is not working.
Could you please check where I am making mistake.
var eom = new GlideDateTime();
eom.setValue(current.parent.subject_person.u_onboarding_hire_date);
eom.setTimeZone("America/New_York");
eom.setDayOfMonthUTC(32);
var arrDate = [];
arrDate = dueDate.toString().split(' ');
//current.due_date = eom;
current.due_date= (arrDate[0]+ ' 23:59:59','yyyy-MM-dd HH:mm:ss');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2024 07:14 AM - edited 02-19-2024 07:29 AM
Hi @lucky24,
I've tweaked your script a little. Try the below.
Questions I had when reviewing the code: Why do you need the array arrDate? Anyway, the below works, I've tested it, and should give you what you want.
To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Helpful.
Thanks, Robbie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2024 11:21 PM
Hi Robbie,
Thanks for the solution.
When I created a record from the India (IST) time zone it was working expected but when I created a record from America/los_Angeles time zone, in native view it showed the correct value but in portal, it is setting the next month of the first day