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
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
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?
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.
[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.
"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?
"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?
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!
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,151 Super User 2024 Season 2
Martin Dráb 229,993 Most Valuable Professional
nmaenpaa 101,156