- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2024 01:47 AM - edited 07-05-2024 01:48 AM
On a form, I'm wanting the Next AMA Due Date field to be updated by 1 year from the current date. The field is being triggered by a flow. The Next AMA Due Date is a Date field. Within my flow, I'm using the current code:
The Last scoping AMA completed date field is showing correctly as that just gets the current date by using gs.now(). Does anyone know what's going wrong with my code and what I can do to get the format correct?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2024 01:50 AM
Try this
var gdt = new GlideDateTime();
gdt.addYearsUTC(1);
gs.info(gdt.getDisplayValue());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2024 01:50 AM
Try this
var gdt = new GlideDateTime();
gdt.addYearsUTC(1);
gs.info(gdt.getDisplayValue());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2024 04:36 AM
Hi @matthew_hughes just checking if this worked or not?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2024 05:04 AM
Hi @Anurag Tripathi Thanks very much. That worked
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2024 01:54 AM
var currentDate = new GlideDateTime();
// Add 1 year to the current date
currentDate.addYearsLocalTime(1);
// Format the date to ensure correct display and storage
var formattedDate = currentDate.getLocalDate().getDisplayValue();
gs.info('Next AMA Due Date: ' + formattedDate);
--------------------------------------------------------------------------------------------------------------------
If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful." This action benefits both the community and me.