krembanan
krembanan

Reputation: 1428

Dynamics CRM subgrid with all related instances of same type

For accounts in Dynamics CRM I have a custom related entity X (one account can have zero or more Xs related to it). On the form of X I want to show a subgrid with all active instances of the same type related to the same account.

Is there a supported way to do this, or do I have to edit the FetchXml on the fly using JS or in the customizations.xml file up front? I have done FetchXml editing in system views to introduce filtering on three or more levels, but I have not done a "loop" before and the same technique fails because the relationship both inwards and outwards in the query is the same.

Upvotes: 0

Views: 2530

Answers (2)

AdamV
AdamV

Reputation: 1467

In CRM 2013 you can use some nice new functionality - Quick View Forms.

Create a new form for Account of type = Quick View

On that new form, add a regular subgrid for the child (related) entity, format as usual, choose an appropriate view for it etc.

(Tip: Edit the form properties to give it a useful name, not just "New Form")

Now on the form for the child entity, add the Quick View form in and link it to the lookup field for the Account. When you choose an Account, it will display the Quick View form, which in turn displays the sub-grid.

Some points here:

  • The subgrid will be read-only, but you would get a similar effect in most other ways unless you build a custom control for the grid. The 'sister' records have no relationship with the current one.
  • The current record will be in the list. Not a big deal, hopefully.
  • By using built-in functionality you should be able to get this to work on browser, Outlook and Tablet client without having to re-engineer this.

Upvotes: 1

Alex
Alex

Reputation: 23300

THIS ARTICLE says that it's doable, not much different than a custom lookup:

  1. Put a subgrid showing all records of entity X
  2. Build the relevant fetchXml query (hint: you can make an Advanced Find and grab the code through 'Download FetchXML' feature
  3. apply the fetchXml to the subgrid (*) and refresh it

(*) The linked page's code usesdocument.getElementById which is unsupported, YMMV (I'd try and see if the same result is achievable through Xrm.Page.controls.get())

Upvotes: 0

Related Questions