Retrieve the fetchxml in grid via javascript

Viewed 1458

This might seem a bit of an odd request so I'll try to offer some background. I have a feature on my CRM which requires that user should be able to filter a view and then save the resulting records such that a separate process can pick them up and process them periodically e.g. daily.

Now here's the catch, they want this process to requery the data before it processes it, so basically what should be saved is the query or filters rather than the data in the view.

Having previously written some javascript code which dynamically sets the fetchxml on a subgrid like so

Subgrid.getGrid().setParameter("fetchXml", fetchxml);

I though it should be fairly straight forward to potentially retrieve the fetchxml in the grid

Subgrid.getGrid().getParameter("fetchXml");

However that doesn't work and I can't seem to find any documentation or anything that can point me in the right direction. I have used Developer tools to inspect the properties of Mscrm.XrmControlGridWrapper but I can't find anything useful..

If anyone knows how I can retrieve the fetchxml that powers a subgrid using javascript, it would be massively helpful?

EDIT

I have just found that I can do this

Subgrid.getGrid().getFilter().$3_1.GetParameter("fetchXml")

and that returns exactly what I want, however this just screams of hacky and unsupported. $3_1 has a type of [object (Mscrm.TurboGridControl)]

Is there a way I can access this object in a supported way?

2 Answers

You can do:

  • Since you have the fetchxml that previously set as filter for SubGrid, why don't you store this variable directly. You can save this variable in localStorage or maybe even in a dummy field created for this purpose. And use it in the desired process.

  • Btw, the supported way of getting fetchXml: Xrm.Page.getControl(gridControlName).getFetchXml()

Hope this helps...

Related