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
Employee
Posts: 1,163
Country: USA

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

I see, this is clearly inefficient but I did it this way because I thought you were saying that it was clearing the first occurrence everytime and I wanted to make sure there wasn't a defect.

 

We can reduce the number of results by using some of the alternate overloads for the GetActivitiesForContact method, I was looking through the code reference and a few accept a System.DateTime parameter, I don't have any examples using this though.

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

Thanx for looking.

 

If you have access to the Calendar code, it should be there, when the user erases an individual event of a recurring series. It must pick up the date from the calendar selection and then just add it to the DeletedDates array. I do not think it expands the series and then finds the correct date (just a thought).

 

Thanx.

 

T

 

 

Highlighted
Astute Commentator
Posts: 197
Country: United States

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

[ Edited ]

Thanx Jim.

 

I'll give that a try. However, I don't think  it may work.

 

We already have the recurrence pattern. What I want to do it add an exception to the pattern i.e. a deleted exception so that i can emulate the Erase process of ACT!.

 

The DeletedDates object of the recurrence pattern has a SetValue and CreateInstance methods that I can't get to work. If anyone at Sage could show me a small piece of code how this works, it would be great.

 

The code should look like something:

 

    ACT_Appointment.DeletedDates.CreateInstance(ElementType, Length)

    ACT_Appointment.DeletedDates.SetValue(dDate, Index)

 

However, I'm having problem figuring out what the CreateInstance is looking for in ElementType and Length as well as how to determine which index to set from a return value in CreateInstance. So with a little bit of help from Sage, maybe I'll be able to resolve this thing this week.

 

T

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

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

T,

Why not delete the activity and let ACT handle the DeleteDates property?

 

-- Jim

 

 

Highlighted
Astute Commentator
Posts: 197
Country: United States

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

Because you have no control as to when in the series you can delete the activity. If you delete the activity instance, it will delete at the StartDate of the Activity and not at the date you want to delete. So if you want to delete an activity in the middle of the series, you really can'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 ]

Do you have a code example of what you are trying to do. Maybe that will help me understand.

 

If you are trying to delete the activity from the recurrence pattern that will be a lot of work.

If you want to mark that activity as cleared, get the single activity instance and

activity.IsCleared = True

activity.Update()

 

You could also delete the activity directly:

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

where allOccurrences is False

 

-- Jim Durkin

 

Highlighted
Astute Commentator
Posts: 197
Country: United States

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

I am using

 

ACTFramework.Activities.DeleteActivity(cActivity, cAccessor, allOccurrences) where allOccurences is False (only delete cActivity).

 

Now, how would one use the call above to delete an individual activity on a particular date i.e. The series is daily, at 4pm, and I want to delete an activity on 8/1/11 ?

 

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 ]

If you post a larger code example I may be able to help. I can not tell what's wrong by just the line that is failing.

 

I'll swag away anyway.

What is the date of cActivity? Is it 8/1/11?

 

I editing this post to include my DeleteActivity Function...

 

 Public Shared Function DeleteActivity(ByVal HostFramework As Act.Framework.ActFramework, _
                                          ByVal cActivity As Act.Framework.Activities.Activity, _
                                         ByVal cAccessor As Act.Framework.ActivityAccessors.ActivityAccessor, _
                                         ByVal bShowMessage As Boolean) As Boolean


        Try
            ' Get the activity from the cActivityID

            If cAccessor Is Nothing Then
                cAccessor = New Act.Framework.ActivityAccessors.ActivityAccessor(cActivity.AccessorId, cActivity.AccessorName, Nothing)
            End If


            If (cActivity.ActivitySeriesAppliedId <> Guid.Empty) Then
                ' This activity is applied to a series
                If Windows.Forms.MessageBox.Show("Are you sure you want to delete this activity series?", "Activity Series", Windows.Forms.MessageBoxButtons.OKCancel, Windows.Forms.MessageBoxIcon.Question, Windows.Forms.MessageBoxDefaultButton.Button2) = Windows.Forms.DialogResult.OK Then
                    HostFramework.Activities.DeleteActivitySeriesItems(cActivity, cAccessor)
                End If

            Else
                ' Single activity NOT Applied to a series
                Dim allOccurrences As Boolean = True

                If (cActivity.RecurSpec.Period <> Act.Framework.Activities.ActivityRecurPeriod.None) Then

                    Dim recurring As New Act.UI.DeleteConfirmationDialogRecurring
                    If (recurring.ShowDialog = Windows.Forms.DialogResult.Cancel) Then
                        Return False
                    End If

                    allOccurrences = recurring.AllOccurrences

                    recurring.Dispose()

                ElseIf bShowMessage Then

                    Dim result As Windows.Forms.DialogResult
                    If cActivity.IsOrganizersInstance = True Then
                        If (cActivity.AssociatedWith.Length > 0) Then
                            result = Windows.Forms.MessageBox.Show("Deleting the selected activity will delete is for all contacts and group/company associations. Do you want to continue?", "Activity", Windows.Forms.MessageBoxButtons.OKCancel, Windows.Forms.MessageBoxIcon.Question, Windows.Forms.MessageBoxDefaultButton.Button2)
                        Else
                            result = Windows.Forms.MessageBox.Show("Are you sure you want to delete this activity?", "Activity", Windows.Forms.MessageBoxButtons.OKCancel, Windows.Forms.MessageBoxIcon.Question, Windows.Forms.MessageBoxDefaultButton.Button2)
                        End If
                    Else
                        result = Windows.Forms.MessageBox.Show("Are you sure you want to delete this activity?", "Activity", Windows.Forms.MessageBoxButtons.OKCancel, Windows.Forms.MessageBoxIcon.Question, Windows.Forms.MessageBoxDefaultButton.Button2)
                        'Windows.Forms.MessageBox.Show("You are not the organizer of this meeting. You can not change it.", "Activity", Windows.Forms.MessageBoxButtons.OK, Windows.Forms.MessageBoxIcon.Stop, Windows.Forms.MessageBoxDefaultButton.Button1)
                        'result = Windows.Forms.DialogResult.Abort
                    End If

                    If (result <> Windows.Forms.DialogResult.OK) Then
                        Return False
                    End If

                End If

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

                Return True
            End If

        Catch ex As Exception
            Throw ex
        End Try

    End Function

 

Thanks

-- Jim Durkin

Highlighted
Astute Commentator
Posts: 197
Country: United States

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

Thanx for the code.

 

I looked at your code, and you are erasing the cActivity object. If the cActivity is an instantiation of, for example, the activity on 8/1/2011 then it will work ok. However, if you are provided with a date, how would an activity be erased?

 

  1- Start a recurring Activity, Daily starting today 7/11/2011, using the ACT! Interface.

  2- Now, how would you erase this activity programmatically on 8/1/2011 without erasing the whole series i.e. how, if you are only provided with a date, would you erase that activity on that particular date?

 

Expanding the whole series and then going though each item until you get the erased activity is not a solution (time and cpu intensive and bad programming). It should be a 3 line piece of code.

 

 

Not sure if I'm making myself clear...

 

T

 

 

 

 

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

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

I wouldn't say it's a three line piece of code because you need to build four parameters to call the ACTFramework.Activities.GetActivityList(aSort, aFilter, StartDate, EndDate) to retrieve the single occurance

 

This is SUDO CODE

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

' Get the sort array

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

Dim aSort As ActivitySortCriteria = New ActivitySortCriteria(OccurDate, System.ComponentModel.ListSortDirection.Ascending)

 

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

' Create an array to hold the filter conditions

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

Dim FilterArray As ArrayList = New ArrayList 

' Create a Type Filter

Dim ActivityIDsFilter As ActivityInFilterCriteria = New ActivityInFilterCriteria(NewActivityFieldDescriptor(ActivityField.ActivityId), MyActivityIDs)

' Add the filter to the array

FilterArray.Add(ActivityIDsFilter )

 

' Convert the ArrayList to an array of IActivityFilterCriteria

Dim aFilter(FilterArray.Count - 1) As IActivityFilterCriteria

FilterArray.CopyTo(aFilter)

 

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

' Get the start and end date

'----------------------------------------------------------
Dim StartDate As DateTime = DateTime.Parse("08/01/11 12:00:00 AM")

Dim EndDate As DateTime = DateTime.Parse("08/01/11 11:59:59 PM")

 

' Dim the Activity List object

Dim MyActivityList AsAct.Framework.Activities.Activity = nothing

 

' Populate the Activity List object

MyActivityList  = ACTFramework.Activities.GetActivityList(aSort, aFilter, StartDate, EndDate)

 

' Delete the activity

ACTFramework.Activities.DeleteActivity(MyActivityList (0), cAccessor, allOccurrences)

 

Hope this helps

-- Jim Durkin