How to change subgrid columns by Javascript (issue with fetchXML) CRM 2013 RRS feed

  • Question

  • Good morning all,

    i have a problem with subgrid and fetchXML, depending of a value from a picklist in my Parent entity, I want to display different columns in a subgrid.

    In order to do that, I use the fetchXML parameter. Problem is that, my columns don't change, only the filter criteria is applied.

    Example : the default view contains columns : Created / Product ID Primaire / Product ID Secondaire.

    I want to add  some columns : Numero de serie (serial number ) / code defaut(default code) / Sous garantie (warranty)

    Syntax used is

    var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>";
        fetchXml += "<entity name='hpe_ligneincident'>";
        fetchXml += "<attribute name='hpe_ligneincidentid' />";
        fetchXml += "<attribute name='hpe_quantiteprimaire' />";
        fetchXml += "<attribute name='hpe_produitprimaireid' />";
        fetchXml += "<attribute name='hpe_numerodeserie' />";
        fetchXml += "<attribute name='hpe_codedefaut' />";
        fetchXml += "<attribute name='hpe_sousgarantie' />";
        fetchXml += "<order attribute='hpe_produitprimaireid' descending='false' />";
        fetchXml += "<filter type='and'>";
        fetchXml += "<condition attribute='hpe_quantiteprimaire' operator='gt' value='3' />";
        fetchXml += "<condition attribute='hpe_incidentparentid' operator='eq' uitype='incident' value='"+ IncidentID + "' />";
        fetchXml += "</filter>";
        fetchXml += "</entity>";
        fetchXml += "</fetch>";

    Problem is that, the criteria IS OK, the restriction on field hpe_quantiteprimaire is well applied BUT, the columns chosen in the attribute name tag are not displayed

    what I am doing wrong ?

    thank you

    Thomas Larcher / HAYWARD POOL EUROPE

    Tuesday, April 29, 2014 9:15 AM

All replies

  • Subgrids and Views have basically two components involved in the rendering:

    1) Fetch component, which determines the data that will render

    2) Format component, which determines how the data is rendered, including things like which columns get rendered and at what width, etc.

    Although you can change the included data 1) through FetchXML you cannot programmatically alter the metadata that determines what and how it will render.  You could potentially do this by creating different views, each with its own set of display fields, then switching between them programmatically.  Or, you could render your own dynamically generated grid view in an IFrame.

    Friday, May 2, 2014 8:07 PM
  • OK

    Do you know how to select by code / jscript a different view ? (it was my initial idea, but I haven't found yet how to do that)

    thank you

    Thomas Larcher / HAYWARD POOL EUROPE

    Wednesday, May 14, 2014 8:00 AM