Due Date on RITM to match a Variable Date

Moe13
Tera Expert

I have a requirement to set the Due Date to a specific variable entered date. I did that using the following script:

	if(current.variables.projected_start_date)
		{
			current.due_date = current.variables.projected_start_date;
			
		}

But when testing, it is display the date to a day before instead of the entered date, For example the entered date is 10/01/23 and it sets the due date to 9/30/23. How do I fix this? Thank you in advance!

4 REPLIES 4

Vishal Birajdar
Giga Sage

Hello @Moe13 

 

Instead of business rule you can set due date through workflow run script.

 

Run script:

current.due_date = current.variables.projected_start_date;

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

How would I complete the Workflow run script. if this is limited to a specific category? I'm an admin with little scripting knowledge. This due date is only to update on a specific request item and not all. Is there another way this can be fixed?

Hello Moe13  

 

Workflow will run specific to catalog item.

 

Please find below Screenshot for reference: 

 

1. Use Run script activity in Workflow

 

VishalBirajdar7_1-1693975253299.png

 

2. Write below Script inside Run script activity

 

var dueDate = current.variables.date;  // you can change variable name as per your item 

var dateObj = new GlideDateTime(dueDate);
current.due_date = dateObj;

 

VishalBirajdar7_2-1693975336798.png

 

 

Output : 

 

VishalBirajdar7_4-1693975513046.png

 

 

 

VishalBirajdar7_3-1693975452154.png

 

 

 

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

Albert
Tera Contributor

Could be a timezone issue? 

 

October 1 in requester's timezone could be Sept 30 in System Timezone. Try impersonating the requester or set your timezone to the requester's timezone and check if the due date changed or reflected. If so, that is a TimeZone issue which is fine.