Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
265
How to set End Date in Case of MaxOccurrences in Recurrence
posted

Hi i am using Custom Datasource and adding a FetchRecurrence method.

Problem i am not able to assign Maxrecurrence in Recurrence activity.

2. One more Problem:

How to Set End date in case of  Maxoccurence:Infragestic is Doing this i check the Database

Suppose i set 10 occurence then how to send End date with weekdays and without weekdays in Database.

Can someone from Infragestic Team Help me to find out about EndDateUTC Logic in Recurrence Table.How you are

Setting EndDate if user select Maxoccur.

Please See code

  private void FetchRecurrences(FetchRecurrencesContext context)
         {

                  Recurrence recurrenceObject = null;
                     recurrenceObject = new Recurrence(null);
                        recurrenceObject.DayOfMonth = ReservationDTO.RecurrenceItemDetails.Dayofmonth;
                      
                     recurrenceObject.MaxOccurrences = 10;//Exception thrown
                   }

 

Thanks

Parents
No Data
Reply
  • 4960
    Suggested Answer
    posted

    There is not enough information to calculate an end date based on the MaxOccurrences here, that is why you get the exception (if I had to guess, it's an NRE because either start or end date is not set?)

    Here is the missing information:

    • recurrenceObject has no start date (it is passed a null root activity in the constructor call. It is the start date on the root activity that is the recurrence's start date, from which any calculation of the number of occurrences must necessarily begin.)
    • recurrenceObject has no period multiple to indicate after every how many months an occurrence should be generated on the DayOfMonth you have set.
    • recurrenceObject has no period set, so it isn't entirely certain whether it should use 'M' (month).  It might infer this because DayOfMonth was set, but it doesn't. It is just expecting to be loaded with the right period.

    In Fetch Recurrences, you should just set the properties from the Recurrence data model, meaning set the EndDateUtc.  MaxOccurrences isn't in the data model because it is a derived field, dependent on other fields for its value.  Don't worry about attaching it to an Activity yet, and don't expect all of its properties to be self-consistent (because the properties have not all been loaded, one property setting isn't going to be enough to calculate all of its properties) during Fetch.

    You can make-up an EndDateUtc the first time (as long as it's in the future), and come back later (when it has been attached to its root activity, and all of its fields have been loaded from the data source) to set MaxOccurrences.  When WebSchedule hands you back the Recurrence object to save later, it will give you the right EndDateUtc.

Children
No Data