Question Status

Suggested Answer
Andrew Ciccarelli asked a question on 1 Mar 2013 12:41 PM

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?

Reply
Suggested Answer
mbrameld responded on 1 Mar 2013 2:34 PM

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?

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.

Reply
Suggested Answer
Aileen Gusni responded on 16 Jul 2014 5:36 AM

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?

Reply
mbrameld responded on 1 Mar 2013 12:58 PM

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!

Reply
Andrew Ciccarelli responded on 1 Mar 2013 1:17 PM

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

Reply
Andrew Ciccarelli responded on 1 Mar 2013 1:20 PM

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

Reply
Suggested Answer
mbrameld responded on 1 Mar 2013 2:34 PM

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?

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.

Reply
minohimself responded on 16 Jul 2014 3:46 AM

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.

Reply
Suggested Answer
Aileen Gusni responded on 16 Jul 2014 5:36 AM

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?

Reply