3

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.

Pedro Azevedo
  • 2,507
  • 1
  • 16
  • 22
Jason N
  • 151
  • 1
  • 1
  • 10

1 Answers1

5

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);
Pedro Azevedo
  • 2,507
  • 1
  • 16
  • 22
Jason N
  • 151
  • 1
  • 1
  • 10
  • Hi Pedro, no additional questions. What I found above, while debugging the plugin, was sufficient enough to resolve my issue. Thanks! – Jason N Mar 02 '13 at 02:14
  • @JasonN please mark one of these (or multiple...forget if this site allows that) as the answer that. – Mike_Matthews_II Mar 12 '13 at 20:56
  • 3
    just to add- you have to register your plugin as a `Post` operation plugin – J. Ed Jun 10 '13 at 12:23
  • 2
    Your statement that Retrieve plugin is called for RetrieveMultiple is incorrect. – link64 Apr 01 '15 at 01:16
  • Thank you this helps me so much, I had a problem that my plugin was never executed and found out that I need to register it as a Post operation plugin. – ichachan Dec 18 '21 at 02:29