Can I use an ActivityPointer object to set the same state for different activities? CRM 2011

I need to make sure that the state of all actions related to the object (incident) in CRM 2011 is completed before I can decide the state of the case itself.

I can do some extraction to get all possible types of activity independently, and then execute the corresponding SetStateRequest (...) for each type. This article seems to suggest that an ActivityPointer entry is created each time an activity type entry is created and that both entries have the same identifier. Of course, when I look at cases and actions, each activity type entry has an associated ActivityPointer entry with the same identifier. So far so good.

Does this mean that I can do one extraction of all ActivityPointer entries related to my case and set the state for them to achieve the setting of the activity state in different types? I suppose I do not understand what the goal of ActivityPointer is, if this does not allow me to do manipulations with the general activity. Is this the point, if so? Also, the ActivityPointer object does not have a SetStateRequest message, so can anyone please explain how I can change the state / status in the ActivityPointer record? Ideally, I want the state completed and the status canceled.

Update: This blog seems to show exactly what I want, but the official docs in SetStateRequest seem to indicate that it does not support the ActivityPointer object. I will try it tomorrow, but if anyone has any advice on the best way, I will be obliged.

Update2: On further reading, I think the situation is that an ActivityPointer object can only have a set of states. Thus, I should be able to set all activity records to cancel status in this setting . I believe it makes sense that I cannot generally set "Status Reason" because it differs between the types of actions. I am still a bit confused in the previous link, because it seems that I can set the state and status of the object, but it is not clear if this is true, what combo values ​​are allowed and what they mean ...

+4
source share
2 answers

Chris. I answer my question here because there is a way to use an activity pointer record to generally close all types of activity. This may be one of the reasons why this entry. He relies on the fact that the record of the activity indicator has a field that determines what activity he represents. Here is the code:

// do a search for all activities that have a status of open or scheduled // that covers them all // here the filter expression to use /* FilterExpression filterStateCode = new FilterExpression(); filterStateCode.FilterOperator = LogicalOperator.Or; filterStateCode.AddCondition("statecode", ConditionOperator.Equal, "Open"); filterStateCode.AddCondition("statecode", ConditionOperator.Equal, "Scheduled"); */ // the search returns a list of entities called AllOpenRelatedActivities foreach (var currentActivityPointer in AllOpenRelatedActivities.Entities) { if (currentActivityPointer.Attributes.Contains("activityid") & currentActivityPointer.Attributes.Contains("activitytypecode")) { currentActivityPointer.LogicalName = currentActivityPointer.Attributes["activitytypecode"].ToString(); currentActivityPointer.Id = (Guid)currentActivityPointer.Attributes["activityid"]; SetStateRequest setState = new SetStateRequest(); setState.EntityMoniker = currentActivityPointer.ToEntityReference(); setState.State = new OptionSetValue(); setState.State.Value = 2; setState.Status = new OptionSetValue(); setState.Status.Value = -1; SetStateResponse setStateResponse = (SetStateResponse)service.Execute(setState); } } 
+5
source

The best way to explain the Activity Index is that it is the base class for classes such as Email and Phone Call.

The activity pointer encapsulates the basic attributes of any activity, so if you create a user activity, it will also propagate to the activity pointer.

It follows that the activity indicator contains the status and state values ​​of all actions, but it also makes sense that it cannot be accessed from SetStateRequest.

I assume that the actual state of Open, Closed, Scheduled, Canceled activity is applicable to all types of activities, but the status is individual for each type of activity.

Eg. the task can be opened, but the reason for its status can also be opened. While the email can also be opened, but the reason for its status is "Waiting for sending"

Due to this differentiation, SetStateRequest will probably not allow you to run it on an ActivityPointer, but it will be for each individual activity object.

In terms of what you intended to do, the supported method would be to get all the related actions separately, and then execute the given status request.

You can do everything right away, however you want, but include a bit of “unsupportability” in that you may have to do this directly in the database. However, when setting the status to “End state”, the reason should also reflect the status related to this state. Otherwise, I believe that the actions will be erroneous.

So, unfortunately, I do not see the way around this in an elegant way, but please update if you find it!

+5
source

Source: https://habr.com/ru/post/1386445/


All Articles