Create a catalog task based on requested item variables
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2023 03:58 AM
I have a requirement to create a catalog task based on a requested item variable:
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2023 06:55 AM
Hi Ankur,
So I've added the timer activity to my workflow:
And this is where I've added the script:
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.
What am I missing?
Many thanks,
Alex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2023 07:28 AM
did you try to add gs.info() and check what came in log for the date?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2023 07:43 AM - edited 04-28-2023 07:50 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2023 07:56 AM
something like this
var terminationDate = current.variables.termination_date.getDisplayValue();
gs.info("Termination Date" + terminationDate);
answer = gs.dateDiff(new GlideDateTime(), terminationDate, true);
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2023 08:20 AM
so I can see that yes the termination date is being pulled through