web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

how to update crm data grid - fetchxml + binding

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • mbrameld Profile Picture
    90 on at

    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!

  • Community Member Profile Picture
    on at

    "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?

  • Community Member Profile Picture
    on at

    "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?

  • Suggested answer
    mbrameld Profile Picture
    90 on at

    [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.

  • minohimself Profile Picture
    2 on at

    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
    Aileen Gusni Profile Picture
    44,524 on at

    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?

  • Suggested answer
    Aman Kothari Profile Picture
    on at

    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

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans