Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

fetchxml and view

Posted on by 40

i want to retrieve custom view ,with fetchxml or query expression in crm plugin with c#

bellow is my code :

var fetchXml =
@"<fetch>
<entity name='invoice'>
<attribute name='customerid' />

<filter type='and'>
<condition attribute='customerid' operator='eq' value='{0}' />
<condition attribute='brd_noncheckout' operator='eq' value='1' />

<condition attribute='statecode' operator='eq' value='0' />
<condition attribute='statuscode' operator='in'>

<value>100000002</value >
<value >4</value >
</condition>
</filter>
</entity>
</fetch>";

CurrentPosition = 33.1;
var request = new RetrieveMultipleRequest()

{

Query = new FetchExpression(string.Format(fetchXml, currentCustomerRef.Id, DateTime .Now ))
};
CurrentPosition = 33.2;
var requestResponse = (RetrieveMultipleResponse)service.Execute(request);

CurrentPosition = 33.3;
//+++++++++++++++++++++++++++++++++++++++++++++++
if (requestResponse.EntityCollection != null)
{
var retOrders = requestResponse.EntityCollection;
CurrentPosition = 33.4;

CurrentPosition = 33.4;

if (retOrders.Entities.Count > 0)

throw new InvalidPluginExecutionException(OperationStatus.Canceled,
"special message.");

}

}

but this code retrieve dada from all invoice view, i creat a custom view thats name is "custom view"

i want my fetchxml code , execute on "custom view" not in "all invoice"

*This post is locked for comments

  • HarryZang Profile Picture
    HarryZang 240 on at
    RE: fetchxml and view

    you can always change the "filter" part of your fetchxml code, just change/add conditions to make sure it is the same as the "custom view" filter condition (you can see the custom view filter criteria when customize the view ).

  • vashti hatami Profile Picture
    vashti hatami 40 on at
    RE: fetchxml and view

    please expain more.

  • Friyank Profile Picture
    Friyank 944 on at
    RE: fetchxml and view

    To use Saved Query

    www.crmanswers.net/.../retrieve-saved-views-userquery-users.html

    check this link

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