> Can I use CREATE FOR EACH in different RULES with the IF statement above them?
No - this is what creates duplicate instances. "CREATE Work FOR EACH xTask" will work on all xTask instances placed into the context by query "FIND xTask WHERE ....." above - not just those constrained by condition in "If".
You need to split the process into multiple processes with conditions from "If" placed into the query. For example, a DoDailyProcessing process would have 5 rules like these:
FIND xTask WHERE xTask.Sched='Daily' AND Task.LastProc<>CURRENT_DATE
CREATE Work FOR EACH xTask WITH Work.Now=xTask.NextReminder, Work.Contact=xTask.Contact, Work.Agent=xTask.Agent, Work.Subject=xTask.Subject
INCREASE xTask.NumUsed BY 1
xTask.LastProc=CURRENT_DATE
xTask.NextReminder=BUSINESS_DAY_FORWARD(xTask.NextReminder,1)
There would be separate processes for weekly and monthly processing. For convenience (e.g. starting the processing) you can call the separate processes from a container process:
DoDailyProcessing
DoWeeklyProcessing
DoMonthlyProcessing
Each separate process will have its own context that will be discarded when the process finishes on return to the container process. Therefore, there will be no creation of duplicate instances.