Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

CRM Dynamics - Views and FetchXml

Posted on by Microsoft Employee

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

  • Suggested answer
    Yadnyesh Kuvalekar Profile Picture
    Yadnyesh Kuvalekar 4,102 on at
    RE: CRM Dynamics - Views and FetchXml

    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.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: CRM Dynamics - Views and FetchXml

    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
    PhuocLV Profile Picture
    PhuocLV 347 on at
    RE: CRM Dynamics - Views and FetchXml

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

  • Verified answer
    Yadnyesh Kuvalekar Profile Picture
    Yadnyesh Kuvalekar 4,102 on at
    RE: CRM Dynamics - Views and FetchXml

    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

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans