Create Catalog task after 30 days from the selected date in variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi All,
I have to create the Catalog task after 30 days from the selected date in the variable.
for example, If I select today's date in the variable and the catalog task should create after 30 days. (i.e, on July 24th).
var termDate = current.variables.term_date;
if (termDate) {
var targetDateTime = new GlideDateTime(termDate + "00:00:00");
//wait until 30 days after Disable IT Access Date
//targetDateTime.addDaysUTC(1);
targetGDT.addDaysLocalTime(30);
var currentDateTime = new GlideDateTime();
var diffSeconds = Math.floor((targetDateTime.getNumericValue() - currentDateTime.getNumericValue()) / 1000);
answer = diffSeconds > 0 ? diffSeconds : 0;
} else {
answer = 0;
}I have created Timer activity and the Timer based on Script, Can you please check and suggest.
And also, please suggest how to test it.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi @dileep0146
Refer:
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
this link has approach
Create a task in flow designer from date variable field on catalog item form
also check this
you can make the flow wait till that date variable and then create the task
it's simple logic and you can achieve it
check this blog and enhance as per your requirement
Flow Designer : Making the flow wait until a specific date time based on a catalog variable
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hey @dileep0146
Try this:
var termDate = current.variables.term_date;
if (termDate) {
var targetDateTime = new GlideDateTime(termDate + " 00:00:00");
// Add 30 days to the selected date
targetDateTime.addDaysLocalTime(30);
var currentDateTime = new GlideDateTime();
// Return the number of seconds the workflow should wait
var diffSeconds = Math.floor(
(targetDateTime.getNumericValue() - currentDateTime.getNumericValue()) / 1000
);
answer = diffSeconds > 0 ? diffSeconds : 0;
} else {
answer = 0;
}
************************************************************************************************************************************
If this response helps, please mark it as Accept as Solution and Helpful.
Doing so helps others in the community and encourages me to keep contributing.
Regards
Vaishali Singh
Servicenow Developer
Linkedin - https://www.linkedin.com/in/vaishali-singh-2273361bb