Create a task based on a date within a Catalog Item

rachelconstanti
Mega Sage

I have a Service Catalog item with a "start date" variable.

I need the workflow associated to the catalog item to create a task 4 days after that "start date".

I would prefer to do this via scripting (which is not an area of expertise).

Any out there able to help with a script?

1 ACCEPTED SOLUTION

Mike Patel
Tera Sage

try below

var gdt = new GlideDateTime(current.variables.start_date);
gdt.addDays(4);
answer = gs.dateDiff(gs.nowDateTime(), gdt + ' 07:00:00', true);

View solution in original post

17 REPLIES 17

Mark Roethof
Tera Patron
Tera Patron

Hi there,

You are mentioning that you prefer to do this thru scripting, and also not an area of expertise.
Why scripting? And if it's not your expertise, why considering this? Who is going to maintain this?

Also: you could easily do this with no scripting. In a workflow for example, just with the available utilities, have a time run 4 days after the start date variable, and then create the task.

What should functionally happen? For example, the task is created far after the creation of the RITM. What if the RITM is already handled then, maybe even closed?

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

I would have done this but I am not seeing the start date variable from the "tree"...

Also I can read scripts just not great at writing them.  I will be the one to maintain.

But what about my question:

What should functionally happen? For example, the task is created far after the creation of the RITM. What if the RITM is already handled then, maybe even closed?

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Long story short, there is an action that needs to happen 4 days from the new hires start date.

All of our agents know not to manually close or mark RITMS and/or REQs as complete.  The workflow will handle that.

The new hire ticket is created with a start date of mm/dd/yyyy.

There are other tasks that are created I just need one to be created 4 days after the start date because of the action that needs to happen to complete the onboarding process.