Make a API workflow for automatic creating a task

Hi bubblers

im making an full automated task management application
and im trying to make a workflow that if a case have an active service attached to it lets say with an interval of every year.. but could also be an interval for every month or every week.. that there should automaticaly get created a repeated task for that case for each interval..

i already have maked the backend API workflow there should do that.. but i cant find the logic in the condition for how to execute that.. both because the intervals are different but also because a case could contain different services with different intervals..

a service contains these fields:
titel
interval
next date
status
and value

and if the next date is lets say May 2026 i want it to automaticaly create a task 30 days before that next date..
but also if the interval is every month and next date is june 2025 i want it to automaticaly create the task 7 days before

hope there is someone out there with a better logic than me there could help with getting this to work :slight_smile:

you can schedule backend workflows and when setting the scheduled date use the built in operators of +days, +weeks etc. , so that your expression could be something like current date/time +days7

hi @boston85719

but doesnt that just do so that it plans it 7 days forward for current date?
i want it to plan 7 days before the service next date field if it is an interval pr month.. but 30 days before the service next date field if it a yearly interval for the service.. and 2 days before if its a weekly interval.. and so on

So then do just that…

i.e. if the interval is monthly then set it to run 30 7 days prior to the next date

if it’s yearly, then set it to run 30 days prior to the next date

And if it’s weekly then set it to run 2 days before the next date

I’d use an Option Set to define the intervals, with attributes for the number of day of the interval, and number of days prior to the next date etc.

1 Like

do i then just make a wokflow “if condition is true” and set the conditon when service interval is yearly ? and then set schedule to service next date's +days -30

and then make a workflow for each interval?
will that be the right way to do it?

so something like this maybe?

That’s one way to do it..

But a better way, if you’re using an option set like I suggested, is just to schedule the workflow dynamically to the Next Date +Days [the dynamic value of the Option Set lead-in attribute] (i.e. 7 Days)

That way you don’t need to use any conditions, and can just use a single workflow.

i already have the intervals as option sets..
but do you mean to then make the action of schedule the API worflow in the create of the service workflow?

as you see here (its on danish tho) but its different intervals for
one time
every week
every 14 days
every month
every second month
every quarter
every half year
and every year

You nee to add attributes to your option set and define the relevant values.

e.g.

interval (days)
Lead time (days)

Where the interval is the number of days to run the WF at, and the lead time is how many days prior to that to do whatever it is you’re tying to do.

note: you’ll have to add some additional logic for the monthly interval, as every month has a different number of days, obviously)

i have never worked with attributes before..
so im not sure how to use them..

can you maybe be a little more specific?


i have now maked the attributes for the option set..
how do i then use them?

i dont understand what this part means…?

The attributes need to be numbers, not dates.

Then just use those numbers in the expressions when adding days.