Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

how to update crm data grid - fetchxml + binding

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello - I have a saved Assignments custom view. This view is associated to the Assignments datagrid on the Company view.

I need to update the FetchXML to include a new column that it does not currently include.

For the Company Assignments datagrid, I need to update 1 of the columns to bind to the new column being returned through the updated FetchXML.

Can you please explain the steps I need to follow to do this?

*This post is locked for comments

  • Suggested answer
    Aman Kothari Profile Picture
    Aman Kothari on at
    RE: how to update crm data grid - fetchxml + binding

    Hi,

    Below link might help you to update fetchXML and grid layout of view.

    crmdynamicsblog.wordpress.com/.../update-fetchxml-and-grid-layout-of-entity-view-using-c-in-crm

    Thanks

  • Suggested answer
    Aileen Gusni Profile Picture
    Aileen Gusni 44,522 on at
    RE: how to update crm data grid - fetchxml + binding

    Hi,

    FetchXML is only for filter by criteria, you should update the layoutxml field to include the column as well.

    LayoutXML will determine the grid layout, columns header forms.

    Is there any reason why you dong use the UI to setting the view, rather than manually update the fetchxml?

  • minohimself Profile Picture
    minohimself 2 on at
    RE: how to update crm data grid - fetchxml + binding

    The problem i see here and im facing right now is that you cannot really observe the view change, but there are definitely ways to udpate your fetch xml, each view is SavedQuery and it contains layout and fetch xml as attributes you might change this values but havent tryed it on normal crm subgrind i only used to those to build custom grids.

  • Suggested answer
    mbrameld Profile Picture
    mbrameld 90 on at
    RE: how to update crm data grid - fetchxml + binding

    [quote user="Andrew Ciccarelli"]

    I'm not seeing a way to do this.  Can you please describe the steps?  Maybe I'm not taking the correct approach?

    [/quote]

    Sure. Click Settings, Customizations, then Customize the System. On the left, expand Entities, then find and expand your Assignments entity. Click on Views under your Assignment entity, then double-click your custom view that is used on the datagrids. On the right, click Add Columns and add whichever columns you would like. Then save and close and publish.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: how to update crm data grid - fetchxml + binding

    "Can you just update the view to add the desired columns?"

    I'm not seeing a way to do this.  Can you please describe the steps?  Maybe I'm not taking the correct approach?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: how to update crm data grid - fetchxml + binding

    "put this in the onLoad event of the form that has your grid"

    But the grid could be used in multiple places right?  For example, my system has an Assignments saved system view named "AE Assignments."  This view is bound to the Company Assignments grid but this view can also be run as a standalone view through Advanced Find.  Therefore, the onload code you described would have to be defined in multiple places.  Is there a way to define this code in 1 central location for the view?

  • mbrameld Profile Picture
    mbrameld 90 on at
    RE: how to update crm data grid - fetchxml + binding

    Can you just update the view to add the desired columns?

    If not, here's how you can set the grid's FetchXML, put this in the onLoad event of the form that has your grid:

    var fetchXml = '<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">' +
    '<entity name="contact">' +
    '    <attribute name="fullname" /> ' +
    '    <attribute name="telephone1" /> ' +
    '    <attribute name="contactid" /> ' +
    '    <order attribute="fullname" descending="false" /> ' +
    '<filter type="and">' +
    '    <condition attribute="statecode" operator="eq" value="0" /> ' +
    '    <filter type="or">' +
    '       <condition attribute="emailaddress1" operator="eq" value="' + email + '" /> ' +
    '       <filter type="and">' +
    '          <condition attribute="lastname" operator="like" value="' + last + '%" /> ' +
    '          <condition attribute="address1_city" operator="eq" value="' + city + '" /> ' +
    '       </filter>' +
    '    </filter>' +
    ' </filter>' +
    ' </entity>' +
    ' </fetch>';

    var grid = document.getElementById("YourGridName");

    grid.control.setParameter("fetchXml", fetchXml);

    grid.control.refresh();

    If you do it this way it's a good idea to set the grid's default view to a view that you know will never return data. If the view does return data, the page will load and the grid will contain that data, then a second later the grid will update to use the new FetchXML. It's a little jarring and not pretty.

    Good luck!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans