Create a catalog task based on requested item variables

Alex Saager1
Tera Contributor

I have a requirement to create a catalog task based on a requested item variable:

 

AlexSaager1_0-1681728849774.png

 

The catalog item is for users to use when staff are leaving, but the issue I have is that all the tasks are generated at the time of the request being submitted (normal behavior) but in some cases this can be for example a month in the future and then we have tasks sitting in queues for say a month with no action needed.

 

Is it possible to generate these tasks based on the date used on the catalog form?

 

So if for example someone is laving on the 01/05/23 then these tasks are created at that time.

 

Hope this is clear any ideas or suggestions would be greatly appreciated

 

Thanks

 

Alex

 

 

 

14 REPLIES 14

Hi Ankur,

 

So I've added the timer activity to my workflow:

AlexSaager1_0-1682689852981.png

And this is where I've added the script:

AlexSaager1_1-1682689906712.png

In testing I've set the termination date to 01/05/2023 (see below) as a test but the task is still being created, I was hoping that this would only get created when the termination date was reached, or have I misunderstood.

 

AlexSaager1_2-1682690119445.png

 

 

What am I missing?

Many thanks,

Alex

 

@Alex Saager1 

did you try to add gs.info() and check what came in log for the date?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

I did not no, do I need to add this to the end of the script and then this would be recorded in the system logs?

Kind regards,

Alex

@Alex Saager1 

something like this

var terminationDate = current.variables.termination_date.getDisplayValue();

gs.info("Termination Date" + terminationDate);

answer = gs.dateDiff(new GlideDateTime(), terminationDate, true);

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

so I can see that yes the termination date is being pulled through

 

AlexSaager1_0-1682695207498.png