I want set the postdate field via system property through BR but postdate value is +12 hrs of opened
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2022 06:04 AM - edited ‎12-27-2022 06:13 AM
Hello,
I have two fields (date and time) start date and end date. I want to add set the end date field value which is greater than 12 hours of start date. but i want to achieve this via system property sho whenever i want to change the hours then i will edit the system property. for example i want to increase the value from 12 hours to 14 so that we can edit system property only..
@Ankur Bawiskar Could you please guide me
(function executeRule(current, previous /*null when async*/ ) {
var gdt = new GlideDateTime(current.opened_at);
gdt.addSeconds(43200);
current.u_postdate = gdt;
current.update();
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2022 06:11 AM
Hi @Ankit20 ,
You can create system property set its value as 12
create BR and add below piece of code in that:-
var hours = gs.getProperty('my_system_property');
// Calculate the end date
var endDate = new GlideDateTime(current.start_date);
endDate.addHours(hours); // add the specified number of hours
// Set the end date field
current.end_date = endDate;
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2022 06:26 AM - edited ‎12-27-2022 06:36 AM
Hi Gunjan,
Thank you for your quick response.
I have tried but it is not working. it is setting the same date and hours are not adding i have tried on my PDI also.
Many Thanks,
Ankit Mahajan