locked
CRM 2011 Using FilteredViews in FetchXML RRS feed

  • Question

  • I have a report in SSRS that was built using FetxhXML and I am using it to create a new report in CRM 2011. I want to make it so it has the "Run on current record" option so I want to add the FilteredView to it. I know how to add FilteredView to SQL queries, but how do you add it to FetchXML queries? I can't seem to find any examples. This is my FetchXML query minus FilteredViews.

    <fetch mapping='logical'>
       <entity name='new_projects'>
          <attribute name='new_projectsid' alias='ProjectId' />
          <attribute name='new_name' alias='ProjectName' />
          <attribute name='new_description' alias='ProjectDescription' />
          <attribute name='new_status' alias='ProjectStatus' />
          <attribute name='new_estimatedhours' alias='ProjectEstimatedHours' />
          <attribute name='new_hours' alias='ProjectActualHours' />
          <attribute name='new_startdate' alias='ProjecStartDate' />
          <attribute name='new_enddate' alias='ProjecEndDate' />
              <link-entity name='new_projectsteps' to='new_projectsid' from='new_projectsteps2id' link-type="outer">
                 <attribute name='new_parentstep' alias='ParentStepName' />
                 <attribute name='new_projectstepsid' alias='ProjectStepId' />
                 <attribute name='new_name' alias='ProjectStepName' />
                 <attribute name='new_description' alias='ProjectStepDescription' />
                 <attribute name='statecode' alias='ProjectStepStatus' />
                 <attribute name='new_estimatedhours' alias='ProjectStepEstimatedHours' />
                 <attribute name='new_hours' alias='ProjectStepActualHours' />
                 <attribute name='new_startdate' alias='ProjectStepStartDate' />
                 <attribute name='new_enddate' alias='ProjectStepEndDate' />
                     <link-entity name='task' to='new_projectstepsid' from='regardingobjectid' link-type="outer">
    		     <attribute name='subject' alias='ProjectStepTaskName' />
    		      <attribute name='statecode' alias='ProjectStepTaskStatus' />
                         <attribute name='description' alias='ProjectStepTaskDescription' />
                         <attribute name='new_estimatedduration' alias='ProjectStepTaskEstimatedDuration' />
                         <attribute name='actualdurationminutes' alias='ProjectStepTaskActualDuration' />
                         <attribute name='actualstart' alias='ProjectStepTaskStartDate' />
                         <attribute name='actualend' alias='ProjectStepTaskEndDate' />
                     </link-entity>
                    <attribute name='new_order' alias='new_order' />
    	  	<order attribute='new_order' descending='false' />
              </link-entity>
              <filter type='and'>
                  <condition attribute = 'new_projectsid' operator='eq' value='@Project'/>
              </filter>
       </entity>
    </fetch>

    So I want to take that and make it work with FilteredViews, any ideas?

    Thanks!

    Monday, June 4, 2012 6:41 PM

Answers

All replies

  • You need to add the enableprefiltering tag to the fetch query. The following link should help you get going with this http://msdn.microsoft.com/en-us/library/gg328288.aspx

    HTH 

    Sam 


    Dynamics CRM MVP | Inogic | http://inogic.blogspot.com| news at inogic dot com

    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    Monday, June 4, 2012 8:54 PM
  • Sam,

    I updated my query based on that link and when I "Run on current record" it returns all data. This is my query now:


    <fetch mapping='logical'>
       <entity name='new_projects' enableprefiltering='1' prefilterparametername='CRM_Filterednew_Projects'>
          <attribute name='new_projectsid' alias='ProjectId' />
          <attribute name='new_name' alias='ProjectName' />
          <attribute name='new_description' alias='ProjectDescription' />
          <attribute name='new_status' alias='ProjectStatus' />
          <attribute name='new_estimatedhours' alias='ProjectEstimatedHours' />
          <attribute name='new_hours' alias='ProjectActualHours' />
          <attribute name='new_startdate' alias='ProjecStartDate' />
          <attribute name='new_enddate' alias='ProjecEndDate' />
              <link-entity name='new_projectsteps' to='new_projectsid' from='new_projectsteps2id' link-type="outer">
                 <attribute name='new_parentstep' alias='ParentStepName' />
                 <attribute name='new_projectstepsid' alias='ProjectStepId' />
                 <attribute name='new_name' alias='ProjectStepName' />
                 <attribute name='new_description' alias='ProjectStepDescription' />
                 <attribute name='statecode' alias='ProjectStepStatus' />
                 <attribute name='new_estimatedhours' alias='ProjectStepEstimatedHours' />
                 <attribute name='new_hours' alias='ProjectStepActualHours' />
                 <attribute name='new_startdate' alias='ProjectStepStartDate' />
                 <attribute name='new_enddate' alias='ProjectStepEndDate' />
                     <link-entity name='task' to='new_projectstepsid' from='regardingobjectid' link-type="outer">
        <attribute name='subject' alias='ProjectStepTaskName' />
         <attribute name='statecode' alias='ProjectStepTaskStatus' />
                         <attribute name='description' alias='ProjectStepTaskDescription' />
                         <attribute name='new_estimatedduration' alias='ProjectStepTaskEstimatedDuration' />
                         <attribute name='actualdurationminutes' alias='ProjectStepTaskActualDuration' />
                         <attribute name='actualstart' alias='ProjectStepTaskStartDate' />
                         <attribute name='actualend' alias='ProjectStepTaskEndDate' />
                     </link-entity>
                    <attribute name='new_order' alias='new_order' />
      <order attribute='new_order' descending='false' />
              </link-entity>
       </entity>
    </fetch>

    Any ideas? Thanks!



    Tuesday, June 5, 2012 4:37 PM