How to set a current date time in HR task due date

ST9
Tera Contributor

Hi,

I wanted to set a current date time in HR task due date, I have created a before insert BR-

(function executeRule (current, previous) {
	var gr = new GlideRecord("sn_hr_core_case");
gr.addQuery("sys_id", current.parent);
gr.query();
if (gr.next()) {
	if(current.short_description=='Request Active Directory ID (ADID)'){
var now = new GlideDateTime();
current.due_date = now;
}}
	
	


It is giving a empty Due date once task is created.

 

2 REPLIES 2

Bharat Daswani
Mega Guru

Hello @ST9,

You can set date/time as stated below.

 

current.due_date = gs.nowDateTime();

 

 

Regards,
Bharat Daswani

 

If provided answer helps you to address your issue, Would request you to Accept the Solution and hit "Helpful". Thank you!

Sagar Pagar
Tera Patron

Hi,

No need to use the GlideRecord in before insert Business rule on HR task table. Try this updated scripts.

if(current.short_description == 'Request Active Directory ID (ADID)'){
var now = new GlideDateTime();
current.due_date = now;
}

 

Thanks,
Sagar Pagar

The world works with ServiceNow