3
votes

I'm looking for some working examples of retrieve message and retrieve multiple message plugin (Early binding). I've failed to find any successfully examples looking on line. I've checked the SDK, and various forums. Links or working examples would be greatly appreciated!

What I'm trying to accomplish is the intercept and update of specific fields before presentation on the UI. I'm able to partially accomplish this via javascript which is the preferred method, but unfortunately the presentation in grids etc.. cannot be handled in this manner.

I found a link online

In this example he's able to intercept the message and update the value, but this appears to only have worked in roll-up 6 (I'm on 10).

Further related to the above posting is one from Chaitany

In this example he is implementing a similar solution as a post-operation and grabbing the property "BusinessEntity" from the context output parameters. (This is confusing to me because I don't see this property defined in the Retrieve Reponse I assume this should be a property of the RetrieveResponse.

Ultimately, I'd like a solution where intercept the retrieve or retrieve multiple,adjust the values for presentation and then revert back if the form is saved.

1

1 Answers

5
votes

For retrieveMultiple:

EntityCollection entities = (EntityCollection)context.OutputParameters["BusinessEntityCollection"];

For retrieve:

Entity entity = (Entity)context.OutputParameters["BusinessEntity"];

The cool thing about retrieve multiple is that any adjustments that you make in retrieve will be applied for retrieve multiple.

After adjustments have been made then it's just a matter of issuing the following:

  • xrm.Attach(phoneNumber);
  • xrm.UpdateObject(phoneNumber);