4

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?

jcjr
  • 1,503
  • 24
  • 40
Obi
  • 3,091
  • 4
  • 34
  • 56

2 Answers2

0

A few thoughts on this:

  1. You can retrieve the SystemForm record, then parse the FormXml to get the ViewId. Then you can retrieve the view from the SavedQuery entity, and get the FetchXML. Here's an example of the ViewId in the FormXml: enter image description here

  2. You could add a boolean field to the entity and when the user saves the set they want to process you can flag those records for the later batch process to retrieve.

  3. When the user identifies the set they want to process you could temporarily create a view (SystemQuery or UserQuery) with the the FetchXML using the "in" operator with the list of Guid's to identify the exact records to process. After using the view to retrieve and process the records, the batch process could delete the view. I would probably be comfortable using this approach up to a few dozen records.

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
  <entity name="account">
    <filter type="and">
      <condition attribute="accountid" operator="in">
        <value>{A1CC84F2-BE0D-E711-8104-00155D6FD705}</value>
        <value>{A3CC84F2-BE0D-E711-8104-00155D6FD705}</value>
        <value>{A5CC84F2-BE0D-E711-8104-00155D6FD705}</value>
      </condition>
    </filter>
  </entity>
</fetch>
  1. If you want to avoid changing the Modified information by setting a boolean flag on the records to be processed, you could create an N:N linking entity and associate the selected records to an instance of that entity.
Aron
  • 3,877
  • 3
  • 14
  • 21
0

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