1
votes

I am writing a Post PLugin changing the owner. When the owner has a substitution manager, the owner is changed to the substitution manager. I tried a service.Update and an AssignRequest, but these throw an exception.

When I post the request my entity cannot update (and then throws "The request channel time out while waiting for reply after 10:00:00"). But like I see there is no recursion, because when I logged it I have only one repetition of log and it has stopped before or on line with update.

var assignedIncident = new AssignRequest
{
  Assignee = substManagerRef, //get it throw another method, alreay checked in test it`s correct
  Target = new EntityReference ("incident", incedentId)
};
service.Execute(assignedIncident);

I tried to write target in another way

Target = postEntityImage.ToEntityReference()

I tried to write simple update but the problem is the same.

Entity incident = new Entity("incident" , incidentId);
incident["ownerid"] = substManagerRef:
service.Update(incident);

Can somebody help me with that? Or maybe show the way to solve it)

1
Did you make sure you don’t have ownerid in filtering attribute of your post update plugin step?Arun Vinoth - MVP
I checked postentityImage.contains.Attribute("ownerid") equals true.Anton Karachev
Image is snapshot of pre/post values. Filtering attribute and Target stores the current transaction values. If you have ownerid in filtering attribute and when you keep on updating the ownerid field - the plugin trigger in loops. Check the plugin execution depth for safe.Arun Vinoth - MVP
I already did it, log in it is by the lines like that 1-2-3-4-5-6, but 7 is after update and it stops.Anton Karachev
do you have the same error when you change this plugin to asynchronous?Pawel Gradecki

1 Answers

0
votes

The plugin is triggering itself and gets in a loop. The system only allows a maximum of 8 calls deep within plugins and that is the reason it throws an error and rolls back the transaction.

To solve this issue redesign your plugin in the following way:

  • Register your plugin on the Update message of your entity in the PreValidation stage.
  • In the plugin pick up the Target property from the InputParameters collection.
  • This is an Entity type. Modify or set the ownerid attribute on this Entity object.

That is all. You do not need to do an update, your modification is now passed into the plugin pipeline.

Note: for EntityReference attributes this technique only works when your plugin is registered in the PreValidation stage. For other regular attributes it also works in the PreOperation stage.