Hello -
I've been working with a custom implementation of the WebSchedule. I'm setting up recurrence and variances, and things seem to be working. I've run into one problem though. When I create a variance to the recurrence pattern, things fire as I'd expect. When I then go back to that variance and update it again, the only method that gets called is UpdateActivity. The challenging part is that the Appointment passed in has no variance flags set. It has no variance key, and IsVariance is set to false. It does get the correct data key, and the only way I've found to identify it as a variance is a strange combination of the IsStandAlone, RecurrenceKey and Recurrence properties.
Has anyone else run into this? Should the UpdateVariance method be called in this situation? I'd like to get rid of the hack which checks a combination of properties if possible...
Thanks!
brassier,
Were you ever able to find the solution to your problem? I'm now encountering the same issue.
Thanks - JP
I do have a solution that passed our testing, but it isn't pretty. When updating an activity, here's what I did to determine if the activity was a variance or not. I assumed it was a variance if:
(1) The appointment has a recurrence key set (meaning the recurrence wasn't deleted) - appt.RecurrenceKey(2) The appointment doesn't have a recurrence object (meaning this variance isn't tied to a recurrence directly (anymore) - appt.Recurrence(3) The appointment is stand-alone (not part of the recurrence anymore) - appt.IsStandAlone(OR)(4) The appointment has a variance key that doesn't equal Guid.Empty - appt.VarianceKey
So I saw 2 scenarios during my testing. One scenario had 1-3 true, and another had 4 true. This all happened right when I found the appt.VarianceKey property (which wasn't visible through intellisense). So there is a chance that #4 will always be true if you use the VarianceKey properly. The big issue I have is that this is kind of a hack. I feel that UpdateVariance should be triggered, but nobody responded to that initial question.
Hope it helps...
There's nothing like barking up the wrong (VarianceUpdate) tree.
After your comment in your last post I looked at my UpdateActivity method (which was getting called upon the Variance Update event), and saw that I needed to add two lines of code in order to "maintain" the RecurrenceKey. Everything else was getting updated correctly.
My UpdateActivity method had the following code to check for the existance of a Recurrence object:
If (editedAppointment.Recurrence Is Nothing) _
OrElse (editedAppointment.Recurrence.DataKey.ToString.Length = 0) Then
Me._mustRemoveRecurrenceID = editedAppointment.GetValue("OldRecurrenceKey", -999) ReucrrenceID = -999
Else ReucrrenceID = Integer.Parse(editedAppointment.Recurrence.DataKey.ToString) End If
I changed the above to:
If Not String.IsNullOrEmpty(editedAppointment.RecurrenceKey) Then
ReucrrenceID = Integer.Parse(editedAppointment.RecurrenceKey)
ElseIf (editedAppointment.Recurrence Is Nothing) _ OrElse (editedAppointment.Recurrence.DataKey.ToString.Length = 0) Then
...adding Not String.IsNullOrEmpty(editedAppointment.RecurrenceKey) to check first for the existence of a RecurrenceKey value first before checking for the Recurrence object.
With these lines in place, UpdateActivity does the job just fine as you mentioned above.
What kills me is that Infragistics doesn't publish the fact that UpdateVariance never gets called.
Once again, thank you for taking the time to help me out. Your help is much appreciated.
Regards,
JP
In this situation I didn't call the UpdateVariance SP. I called the UpdateActivity SP. A variance is really just an activity, and the UpdateActivity proc had everything that we cared about.
I'm trying to think through if the OriginalStartDateTimeUtc will change when you update a variance. I don't think it will. My thought is that it will only change when the base recurrence changes? And when the base recurrence changes, I'm not sure if the UpdateVariance method/proc is called. It might be worth checking.
Thank you very much for the replay. I was nearly finished with implementing your logic, and everything looked good until I got to updating the variance (calling the UpdateVariance SP).
Because my CustomDataProvider think that the update is for an Activity, there is no OriginalStartDateTimeUtc value for the UpdateVariance SP. How did you work around this issue?