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)

CRM Dynamics - Views and FetchXml

(0) ShareShare
ReportReport
Posted on by

Hi,

I need to retrieve the underlying xml for a view for which i have the view-id.

Can i get a suggestion as to how this can be implemented.

Thanks.

 

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Yadnyesh Kuvalekar Profile Picture
    4,102 on at

    Hi Prakash,

    Using C# code, you can fetch view's XML as per below:

    string fetchQuery = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
                                          <entity name='savedquery'>
                                            <attribute name='name' />
                                            <attribute name='fetchxml' />
                                            <attribute name='layoutxml' />
                                            <attribute name='savedqueryid' />
                                            <order attribute='name' descending='false' />
                                            <filter type='and'>
                                              <condition attribute='savedqueryid' operator='eq' value='<your view id>' />
                                            </filter>
                                          </entity>
                                        </fetch>";
                EntityCollection eb = _OrgService.RetrieveMultiple(new FetchExpression(fetchQuery));


    In FetchXml and LayoutXml fields, you can get Xml.

    Also, FYI, you can use Download FetchXml option to download xml of a view from advance find window. Below is the screenshot.

    advance_5F00_find_5F00_fetchxml.png

  • Suggested answer
    PhuocLV Profile Picture
    347 on at

    You can use this managed solution: https://viewfetchxml.codeplex.com to easy view fetchxml in the advanced find.

  • Community Member Profile Picture
    on at

    Hi Yadnyesh,

    Thanks for your answer it works well. I have another query is it possible to nest fetchxml together like in this fetchxml I get the data :

    <fetch version="1.0" mapping="logical" >

       <entity name="jgs_leadcourse" >

           <attribute name="jgs_name" />

           <attribute name="createdon" />

           <filter type="and" >

               <condition attribute="statecode" operator="eq" value="0" />

           </filter>

           <attribute name="jgs_leadid" />

           <attribute name="jgs_assignedtoid" />

           <attribute name="jgs_assignedon" />

           <attribute name="jgs_sourceid" />

           <attribute name="jgs_ishighlyrated" />

           <attribute name="jgs_leadcourseid" />

           <attribute name="jgs_approvalstatus" />

           <attribute name="jgs_approvaldiscount" />

           <order attribute="createdon" descending="true" />

       </entity>

    </fetch>

    and this is xml defining the data-definition on the visualization of a chart which i have fetched using visualization-id :

    <datadefinition>

       <fetchcollection>

           <fetch mapping="logical" aggregate="true" >

               <entity name="jgs_leadcourse" >

                   <attribute groupby="true" alias="_CRMAutoGen_groupby_column_Num_14" name="modifiedon" dategrouping="week" />

                   <attribute alias="_CRMAutoGen_aggregate_column_Num_15" name="jgs_name" aggregate="count" />

                   <attribute groupby="true" alias="_CRMAutoGen_groupby_column_Num_16" name="jgs_approvalstatus" />

               </entity>

           </fetch>

       </fetchcollection>

       <categorycollection>

           <category alias="_CRMAutoGen_groupby_column_Num_14" >

               <measurecollection>

                   <measure alias="_CRMAutoGen_aggregate_column_Num_15" />

               </measurecollection>

           </category>

       </categorycollection>

    </datadefinition>

    i am trying to put them together, any suggestions.

    Thanks.

  • Suggested answer
    Yadnyesh Kuvalekar Profile Picture
    4,102 on at

    Hi Prakash,

    I have never worked on XML of chart's visualization. Though I research a bit about it, please check if below link if helpful to you.

    crmchartguy.wordpress.com/.../crm-chart-xml

    Thanks & Regards,

    Yadnyesh Kuvalekar

    Kindly tick verify answer if this resolves your query.

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