I want set the postdate field via system property through BR but postdate value is +12 hrs of opened

Ankit20
Tera Contributor

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

 

right now i am using below server code(BR) code to set the value but i want to achieve this via System property.

(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);

 
@Ankur Bawiskar  Could you please guide me
2 REPLIES 2

Gunjan Kiratkar
Kilo Patron
Kilo Patron

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

Ankit20
Tera Contributor

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