I’ve searched everywhere and there doesn’t seem to be a guide on creating a new recurring task even though that feature has already been added. I tried creating one with the Add() function but I cant seem to fill up the RecurrencePattern field in the RecurringTaskParameters.
Also how would I set the pattern? like daily, monthly, etc.
@cruzalbert1986
We have logged your requirement with ID “TASKSNET-3008” for further investigation. You will automatically be informed here once we have more information to share.
I finally figured it out myself but it won’t calculate the proper dates of the children. Like I set a task to recur every week every Tuesday and Wednesday starting on June 12, 2000 and have four occurrences.
The resulting children has dates that are just next to each other, June 12,13,14,15 instead of June 13,14,20,21.
using this code
RecurringTaskParameters recurringSettings = new RecurringTaskParameters();
recurringSettings.Duration = duration;
recurringSettings.IgnoreResourceCalendar = true;
recurringSettings.TaskName = “Test”;
var range = new EndAfterRecurrenceRange();
range.Start = startDate;
range.OccurrenceNumber = 4;
recurringSettings.RecurrencePattern.RecurrenceRange = range;
var task = (project.RootTask.Children.Add(recurringSettings);
task.RecurringInfo.RecurrencePattern = RecurrencePattern.Weekly;
task.RecurringInfo.WeeklyRepetitions = 1;
task.RecurringInfo.WeeklyDays = WeekdayType.Monday | WeekdayType.Tuesday
@cruzalbert1986
Thank you for your feedback.
You may use the following code sample for creating recurring task:
var project = new Project("c:\\Blank2010.mpp");
var parameters = new RecurringTaskParameters
{
TaskName = "Recurring task",
Duration = project.GetDuration(1, TimeUnitType.Day),
RecurrencePattern = new WeeklyRecurrencePattern
{
Repetition = new WeeklyRepetition
{
RepetitionInterval = 2,
WeekDays = WeekdayType.Sunday | WeekdayType.Monday | WeekdayType.Friday,
},
RecurrenceRange = new EndByRecurrenceRange
{
Start = new DateTime(2018, 7, 1, 8, 0, 0),
Finish = new DateTime(2018, 7, 20, 17, 0, 0),
}
}
};
project.RootTask.Children.Add(parameters);
You may also use MonthlyRecurrencePattern, DailyRecurrencePattern or YearlyRecurrencePattern.
Moreover, please try this code and provide your feedback to us.
1 Like
Thank you for this.
I have a follow up question, is it possible to edit a recurring task? Like the task is initially set the Occurrence by 4 but on a later function it needs to be on 8 occurences.
I tired task.RecurringInfo.Occurrences = 8 but it doesn’t seem to work.
@cruzalbert1986
Please share your code sample to understand the scenario and investigate it in detail.
Project project = new Project(“blank.mpp”); //this file already has an existing recurring task that has 4 occurrences
//need to update it so it recurs 8 times now
project.RootTask.Children[0].RecurringInfo.Occurrences = 8;
//recurring task is stil 4 instead of 8
@cruzalbert1986
Thank you for your feedback.
We are investigating this issue and will update you soon.
@cruzalbert1986
We have logged an issue for update occurrences with ID “TASKSNET-3018” for further investigation. We will update you here once we have more information to share.
1 Like
I also would like to add, when adding a predecessor (TaskLink) on a recurring task, it’s children stays the same and doesn’t recalculate based on the predecessor value
@cruzalbert1986
Thank you for your feedback. We will investigate predecessor issue as well and we will update you here in this regard.