07-05-2010 11:13 PM
i am trying to alter activities as they are being created.. first i create the hander and event and this all works good.. the problem is that when i try to change something nothing happens with it
AddHandler ActApp.ActFramework.Activities.CreateActivityComplete, AddressOf ActivityComplete
Private Sub ActivityComplete(ByVal activity As Act.Framework.Activities.IActivity)
'if the regarding line is not complete, then complete it for them
If activity.Regarding = "INSPECTION" Then
activity.Regarding = "INSPECTION - $120 Mazada WA12121"
'activity.Update() <-- really doesnt like this
End If
End Sub
so i can step through the code and can see that firs teh activity.regarding says "INSPECTION" then after its changed i can see it then has set the new text.. but looking at the calendar (even after a refresh) the regarding text still says only INSPECTION
If i try to tell it to UPDATE then it does not like that, obviously its not fully added to teh DB yet and not all contacts have been added etc
I need an event that the activity is REALLY complete and added so that i can pull info from it and work out what to change.. then change properties of the activity and save it
Oz
07-06-2010 08:22 AM - edited 07-06-2010 08:24 AM
Even if you check for activity.ExistsInDB prior to calling the update you get the same message about the activity being deleted.
I was able to work around it though by iterating through the activitylist for the current contact in the CreateActivityComplete event.
ActivityList al = ActApp.ActFramework.Activities.GetActivitiesForContact(ActApp.ApplicationState.CurrentContact, FirstInstanceRestriction.None);
foreach (Activity a in al) { if (a.Regarding == "Test") { a.Regarding = "Modified"; } a.Update(); }
07-06-2010 08:22 AM - edited 07-06-2010 08:24 AM
Even if you check for activity.ExistsInDB prior to calling the update you get the same message about the activity being deleted.
I was able to work around it though by iterating through the activitylist for the current contact in the CreateActivityComplete event.
ActivityList al = ActApp.ActFramework.Activities.GetActivitiesForContact(ActApp.ApplicationState.CurrentContact, FirstInstanceRestriction.None);
foreach (Activity a in al) { if (a.Regarding == "Test") { a.Regarding = "Modified"; } a.Update(); }
07-06-2010 04:37 PM - edited 07-06-2010 04:53 PM
Thanks Matt
your work around does work.. have to keep in mind thou that the activity might not be for the current contact obviously since you can select in the drpodown activity creation for who..
The GetActivitiesForContact takes along time to complete and once complete returns with more items than are really there ( i am looking into this.. it said there were two appointments yet in the activity view of the contact with show ALL of everything only listed one, and that was one the activity was created)
this works much faster
Dim Guids(0) As Guid
Guids(0) = activity.MasterActivityId
Dim al As ActivityList = ActApp.ActFramework.Activities.GetActivityInstancesByActivityId(Guids)
its a pity the activity object that is present in the CreateActivityComplete is not very useful and a let down especially as it must not really be complete yet since it cant be updated.. the extra call to get a list of items takes too long and a let down that i already have the activity object there
07-08-2010 07:47 AM
I was aware there would be some limitations with that solution (slow and doesn't work for the current contact), I was mostly just wanting to get back to you with something that worked. This isn't working as intended so hopefully this will be resolved in the not so distant future.
07-08-2010 09:25 PM
was more just pointing to anyone else looking at using the code to as to what to keep in mind..
for now the work around is working fine, even if its a bit clunky