0

In CRM for every entity, we have the base table and the view (which creates relationship to other entity and has much more attributes).

My question is that is it possible from a plugin to retrieve the attributes from the view instead of the base table?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Nick
  • 780
  • 2
  • 13
  • 33

2 Answers2

1

By view you mean the View of an Entity? Like the view you use in Subgrids or at homepages of each entity?

If so, my guess would be to get the FetchXml of the view you want, then run it on Plugin. After that you have a normal entityCollection Result from the fetchXml execution and you have all the data you can get from that view

MagicD
  • 36
  • 3
1

The "view" (I assume you mean "filteredcontact" for example) is a sql construct that joins stuff like optionsets and lookup objects into your base table whereas the plugin runs at the application level. The view is designed to make it easier to query the record in a sql query. When you query within a plugin, you don't really have the option to hit the view. The object you query against is surfaced via the OrganizationService, which is not exactly equivalent to either the base table or the view.

If you want to get the option set label, you can use the "formatted values", see here: retrieve the value selected in optionset field and display ita value in a text field. If you want the lookup name, that is provided as part of the lookup object which is returned in retrieving the entity. I haven't needed any other items outside these two data points, so I'm not sure what else you would need.

Community
  • 1
  • 1
Joseph Duty
  • 775
  • 5
  • 14
  • I mean by "View" contact NOT filteredcontact or ContactBase. Is using FetchXML from a plugin will give me access to contact, filteredcontact or contactBase? – Nick Oct 10 '15 at 21:46