Community
Showing results for 
Search instead for 
Do you mean 
Reply

Creating a DeletedDates item and/or creating a ClearedDates item on Recurring Event

Highlighted
Astute Commentator
Posts: 197
Country: United States

Re: Creating a DeletedDates item and/or creating a ClearedDates item on Recurring Event

Thanx.

 

The code really helps. You'd think there would be an easier way of doing it.

 

When going through the list, i've added one more check to see if the assessorID matches the user accessing the activity. If you have 3 users that are part of the Activity, you'll get 3 identical activities with the same ActivityID and you'll have to clear the correct one.

 

Also, anothe issue to check is to search for the Activity by MasterActivityID instead of ActivityID. The ActivityID seems to change constantly depending on how the series is cleared and modified. It appears to me the only reliable pointer is the MasterActivityID.

 

Any ideas on that?

 

T

Highlighted
Bronze Super Contributor
Posts: 1,284
Country: USA

Re: Creating a DeletedDates item and/or creating a ClearedDates item on Recurring Event

Change your filter criteria

 

Dim MasterActivityIDsFilter As ActivityInFilterCriteria = New ActivityInFilterCriteria(NewActivityFieldDescriptor(ActivityField.MasterActivityId), MyMasterActivityIDs)

FilterArray.Add(MasterActivityIDsFilter)

 

Dim AccessorIDsFilter As ActivityInFilterCriteria = New ActivityInFilterCriteria(NewActivityFieldDescriptor(ActivityField.AccessorId), MyAccessorIDs)

FilterArray.Add(AccessorIDsFilter)

 

Hope this helps

-- Jim Durkin

Highlighted
Astute Commentator
Posts: 197
Country: United States

Re: Creating a DeletedDates item and/or creating a ClearedDates item on Recurring Event

Jim,

 

Thanx. That helped. It is nice that you can delete an individual instance of a recurring option. Lot of work just to get to it!

 

Now, the next step is to be able to modify an individual instance of a recurring event. I see that the way it is done by the calendar is that it creates a duplicate, non-recurring event for that slot and then adds the date to the DeletedDates list. Can this be done automatically? Currently, even if I select a recurring instance at a future date, if I modify it and save it, it modifies the whole series. Any idea on how to modify only the single instance without affecting the whole series?

 

T

 

 

Highlighted
Bronze Super Contributor
Posts: 1,284
Country: USA

Re: Creating a DeletedDates item and/or creating a ClearedDates item on Recurring Event

You can edit an activity using the ACT UIActivityManager. ACT! UI will ask the users if they want to save changes to just the current activity or all recurring activities.

'-------------------------------------------------------------------------------

' Call the ACT UIActivityManager to edit the activity

'-------------------------------------------------------------------------------

If ACTApplication.UIActivityManager.EditActivity(cActivity, lShowDetails) = Windows.Forms.DialogResult.OK Then

   Return True

Else

   Return False

EndIf

 

OR
If you need to do it all in code then Delete the cActivity from the recurrance pattern and create a new activity directly

'-------------------------------------------------------------------------------

' Delete your desired activity

'-------------------------------------------------------------------------------

ACTFramework.Activities.DeleteActivity(cActivity, cAccessor, allOccurrences)

 

'-------------------------------------------------------------------------------

' Create a new activity

'-------------------------------------------------------------------------------

Dim cActivityTemplate As Act.Framework.Activities.ActivityTemplate = Nothing

cActivityTemplate = HostFramework.Activities.CreateActivity(StandardActivityType.Meeting)

 

'-------------------------------------------------------------------------------

' Set the current contact

'-------------------------------------------------------------------------------

cActivityTemplate.ActivityContacts =

New ActivityContactCollection(HostFramework.Contacts.GetContactAsContactList(HostApplication.ApplicationState.CurrentContact))

 

'-------------------------------------------------------------------------------

' Save the template

'-------------------------------------------------------------------------------

cActivityTemplate.Update()

 

-- Jim Durkin

Highlighted
Astute Commentator
Posts: 197
Country: United States

Re: Creating a DeletedDates item and/or creating a ClearedDates item on Recurring Event

Jim,

 

Actually, if you retrieve the instance from a recurring series, modify it and then save it, the update creates an individual instance of the activity i.e. it creates a new activity and set the DeleteDates in the DeleteDates object for the recurring activity. Quite neat. So that does all the work. However, there are some unexpected side effects.

 

The ID's all change for the object being saved. So if you retrieve the instance and then save it, all the ID's change on the "same" activity object.  That threw my application into a real spin... Also, if you save the same original object twice, 2 identical instances of that individual activity are created on the Activities table. So you'll need to look at those things.

 

Also, before you save, you need to set the RecurringSaveState (I think that is the name of the flag, I'll check tomorrow) to Savethis instead for Save all. My system is off now and I'll post what the flag is to save it as an individual item.

 

I'll have to do some rewriting tomorrow to take this into account.

 

T

 

 

 

 

Highlighted
Employee
Posts: 1,163
Country: USA

Re: Creating a DeletedDates item and/or creating a ClearedDates item on Recurring Event

I think a great deal of the confusion regarding recurring activties stems from the fact that it's simply not possible to create every instance of the series at the time the series is created. Doing so would mean that a single daily recurring activity for multiple users would consume very large amounts of hard disk space as thousands of rows would need to be added to the table.

 

When a single occurrence of an acitvity series is cleared or modified it does create a new instance of this activity, it does so because the activity may not be cleared for every user involved in the activity. However, a date must be added to the DeletedDates collection for the original to let all the attendees know that a user will not be in attendence.

Matthew Wood
Act! SDK Support
Community Moderator
Highlighted
Astute Commentator
Posts: 197
Country: United States

Re: Creating a DeletedDates item and/or creating a ClearedDates item on Recurring Event

Confusion, no! Discovery, yes. Since there is no docs on this and I had to build a special debugging tool to figure it out and see what happens when particular (and many times strange) things happen. Allow me to clarify how individual recurring instances actions work:

 

   - Erase. When you erase a recurring instance, a date is added to the DeletedDates array. Nothing else is done. I've asked for a snipped of code on how this can be done easily but nothing has been forthcoming.

 

   - Modify. Two actions happen here: first, the date is added to the DeletedDates array and second, an individual instance is created and severed from the recurring series. The modified instance is now an independent, stand-alone activity. Since the date is in the DeletedDates array, the calendar will not display on this date.  

 

  - Clear. Two actions happen here: first, the date is added to the ClearedDates array and second, an individual instance is created. It is not, however, severed from the recurring series. The RecurrSourceID points to the original recurring series so when it is uncleared, it dissapears and the ClearedDates in then updated. There are a couple of bugs on the handling of the cleared activities:

    - When an activity is cleared, the cleared instance has all the same IDs as the recurring event. Pretty weird. The only difference is the date and the cleared flag.

    - The details do not get saved when an activity is cleared, only the subject line.

    - If you unclear the cleared activity, all the cleared activities details are permanently lost.

    Conclusion on Cleared Activities: They do not keep history well since a lot of the details are lost. When using recurring activities, it is far better to use the modification of the activity.

 

 To perform the modify action, you need:

             1-  to retrieve the the instance

             2- Set the RecurChangeOption = RecurringChangeOption.This

             3- And then save it with whatever mods you have.

 

There are a couple of things to look for:

   - ID's, depending on the action, will change. Hence, the ActivityID of your object will change halfway through an update. If you are keeping track of the ID's, this can be pretty catastrophic.

   - FirstInstance on a recurring series gets clobbered if you erase the original instance. So you'll get a series without FirstInstance (pretty weird).

 

Now, it would be nice to get a piece of code that shows how to manipulate the DeletedDates/ClearedDates arrays....

 

Well, that is most of what I've come accross....

 

T

Highlighted
Bronze Super Contributor
Posts: 1,284
Country: USA

Re: Creating a DeletedDates item and/or creating a ClearedDates item on Recurring Event

"Conclusion on Cleared Activities: They do not keep history well since a lot of the details are lost.

When using recurring activities, it is far better to use the modification of the activity."

 

The history of the activity is kept inside the history table. You can get the complete activity history using the history class. Activities can be cleared and uncleared multiple time so you may find multiple history records for one activity.

 

HostFramework.Histories.GetHistories(cActivity)

 

Hope this helps

-- Jim Durkin

Highlighted
Astute Commentator
Posts: 197
Country: United States

Re: Creating a DeletedDates item and/or creating a ClearedDates item on Recurring Event

You are quite correct. For the life of me I couldn't find the cleared item in the history. Even though it displays on the calendar as cleared I could not find it in the history list. Until I found that what appears on the Calendar really does not match the history.

 

Do the following:

    - right click on a daily activity instance (daily recurring, starting from today, 7/12/2011), for example on 9/1/11 on the calendar and then select clear.

   - From the display, just select the OK button

   - The activity is now cleared.

 

The calendar will show the activity was cleared on 9/1/11

 

However, the history will show it was cleared on 7/12/2011, the day of the first instance of the recurring event.

 

Maybe this is another bug that should be addressed with 2012.

 

T

Highlighted
Bronze Super Contributor
Posts: 1,284
Country: USA

Re: Creating a DeletedDates item and/or creating a ClearedDates item on Recurring Event

[ Edited ]