- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2024 02:51 AM
Hi all,
I have a requirement to get the current date, add a given no of days to that date and set the date to a date field in logged in user's format in a Business Rule. How can I achieve it?
Thanks in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2024 07:36 AM
Hello @Community Alums ,
Here is the code for your requirement:
var currentDate = new GlideDateTime();
function addDays(dateTime, days) {
var gdt = new GlideDateTime(dateTime);
gdt.addDaysUTC(days);
return gdt;
}
var daysToAdd = 10;
var newDate = addDays(currentDate, daysToAdd);
var userDateFormat = gs.getProperty('glide.sys.date_format');
var formattedDateString = newDate.getLocalDate().getDisplayValueInternal();
current.your_date_field = formattedDateString;
gs.info("Formatted Date: " + formattedDateString);
If you find my response helpful, please consider marking it as the 'Accepted Solution' and giving it a 'Helpful' rating. Your feedback not only supports the community but also encourages me to continue providing valuable assistance.
Thanks,
Amitoj Wadhera
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2024 07:36 AM
Hello @Community Alums ,
Here is the code for your requirement:
var currentDate = new GlideDateTime();
function addDays(dateTime, days) {
var gdt = new GlideDateTime(dateTime);
gdt.addDaysUTC(days);
return gdt;
}
var daysToAdd = 10;
var newDate = addDays(currentDate, daysToAdd);
var userDateFormat = gs.getProperty('glide.sys.date_format');
var formattedDateString = newDate.getLocalDate().getDisplayValueInternal();
current.your_date_field = formattedDateString;
gs.info("Formatted Date: " + formattedDateString);
If you find my response helpful, please consider marking it as the 'Accepted Solution' and giving it a 'Helpful' rating. Your feedback not only supports the community but also encourages me to continue providing valuable assistance.
Thanks,
Amitoj Wadhera