December 14, 2012, 2:03 pm - James Farrer
This has come up a couple of times in the last couple days so I thought I'd post it here for future reference.
When you have a date variable in a catalog item and you need to assign a task or do something X number of days before or after the date then you can use this script in a workflow Timer activity. I made some adjustments to make it easier to put in the number of days. Be sure to replace var_name with the name of the date variable you're using.
// Number of days to wait after the date in var_name (for days before the date, use negative numbers
var number_of_days = 1;
// Calculate x number of days after the due date and convert to seconds
var time = (parseInt(gs.dateDiff(gs.nowDateTime(), current.variable_pool.var_name
// Set 'answer' to the number of seconds this timer should wait
answer = time;
Did something change when pasted? My SN throws "Missing radix parameter" with the above.
There is an optional second parameter for the parseInt function that, depending on the version of your SN syntax editor, can cause a warning. Since the parameter is optional it shouldn't affect the result of the code. I have updated the code to include the second parameter. Thanks.
This was really helpful ! Thanks !! :)