Assigning termination task date to due date

gayatri38
Giga Guru

I have a file form and in that form there is a termination date field on the form. So whenever state is moving from transmission to terminate some tasks are getting created based on conditions and in those tasks i have a due date field so whenever the tasks are getting created we should assign the termination date field to due date field for all tasks .I have created a BR  for it , Its assigning the termination date but termination date is a date field and due date is date and time field so when populating if i give termination date as 31-06-2024 its taking the value as 30-06-2024 7:00:00. Any way if we can put the same date?

 

The script is 

var gr = new GlideRecord("file_task");

gr.addQuery("file_rout", current.sys_id);

gr.query();

while(gr.next()){

   gr.due_date = current.termination_date;

   gr.update();

}

1 ACCEPTED SOLUTION

Amitoj Wadhera
Kilo Sage

Hi @gayatri38 

 

Understood please try the below script:

 

var gr = new GlideRecord("file_task");
gr.addQuery("file_rout", current.sys_id);
gr.query();

while (gr.next()) {
var terminationDate = new GlideDateTime(current.termination_date);
var dueDateTime = new GlideDateTime(terminationDate);
dueDateTime.addSeconds(86399);
gr.due_date = dueDateTime;
gr.update();
}

 

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

View solution in original post

4 REPLIES 4

Amitoj Wadhera
Kilo Sage

Hi @gayatri38 ,

 

Below is the adjusted Business Rule script:

var gr = new GlideRecord("file_task");
gr.addQuery("file_rout", current.sys_id);
gr.query();

while (gr.next()) {
    var terminationDate = new GlideDate(current.termination_date);
    var dueDateTime = new GlideDateTime(terminationDate);
    dueDateTime.setDisplayValue(dueDateTime.getDisplayValue() + " 23:59:59");
    gr.due_date = dueDateTime;
    gr.update();
}

 

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

Hi @Amitoj Wadhera  - Currently this script is in a scoped application and GlideDate is throwing an error .

Amitoj Wadhera
Kilo Sage

Hi @gayatri38 

 

Understood please try the below script:

 

var gr = new GlideRecord("file_task");
gr.addQuery("file_rout", current.sys_id);
gr.query();

while (gr.next()) {
var terminationDate = new GlideDateTime(current.termination_date);
var dueDateTime = new GlideDateTime(terminationDate);
dueDateTime.addSeconds(86399);
gr.due_date = dueDateTime;
gr.update();
}

 

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

thanks , it worked.