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

@Alex Saager1 

seems the date format is the issue. try to convert it into YYYY-mm-DD

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

Hi Ankur,

So I've updated the script as suggested but the tasks are still being generated?

so script now reads:

 

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

var formatdate = day.getByFormat("yyyy-MM-dd");

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

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

 

Alex

@Alex Saager1 

is that the complete script?

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

yes it is, am I missing something?

AlexSaager1_0-1683623353605.png