locked
Can we use fetchXML in ms crm 4.0 plugin? RRS feed

  • Question

  • Hi All,

    Can we use fetchXML in ms crm 4.0 plugin.

    If yes please give me some example.

    Thank you

    Suresh Kumar Patra
    Wednesday, June 20, 2012 10:35 AM

Answers

  • Hi Suresh Kumar

    // Retrieve all accounts.
    // Be aware that using all-attributes may adversely affect performance
    // and cause unwanted cascading in subsequent updates.
    // A best practice is to retrieve the least amount of data required.
    string fetch1 = "<fetch mapping='logical'>";
    fetch1 += "<entity name='account'><all-attributes/>";
    fetch1 += "</entity></fetch>";
    
    // Fetch the results.
    String result1 = service.Fetch(fetch1);
    
    // Retrieve all accounts owned by the user who has read access rights to the accounts and
    // where the last name of the user is not Cannon.
    string fetch2 = @"
       <fetch mapping='logical'>
          <entity name='account'>
    <attribute name='accountid'/>
    <attribute name='name'/>
    <link-entity name='systemuser' to='owninguser'>
       <filter type='and'>
          <condition attribute='lastname' operator='ne' value='Cannon' />
       </filter>
    </link-entity>
          </entity>
       </fetch>
       ";
    
    // Fetch the results.
    String result2 = service.Fetch(fetch2);

    Please check MSDN for more details
    http://msdn.microsoft.com/en-us/library/bb928434.aspx


    I hope this helps. If my response answered your question, please mark the response as an answer and also vote as helpful.
    Mubasher Sharif
    Check out my about.me profile!
    http://mubashersharif.blogspot.com
    Linked-In Profile
    Follow me on Twitter!


    Wednesday, June 20, 2012 10:37 AM

All replies

  • Hi Suresh Kumar

    // Retrieve all accounts.
    // Be aware that using all-attributes may adversely affect performance
    // and cause unwanted cascading in subsequent updates.
    // A best practice is to retrieve the least amount of data required.
    string fetch1 = "<fetch mapping='logical'>";
    fetch1 += "<entity name='account'><all-attributes/>";
    fetch1 += "</entity></fetch>";
    
    // Fetch the results.
    String result1 = service.Fetch(fetch1);
    
    // Retrieve all accounts owned by the user who has read access rights to the accounts and
    // where the last name of the user is not Cannon.
    string fetch2 = @"
       <fetch mapping='logical'>
          <entity name='account'>
    <attribute name='accountid'/>
    <attribute name='name'/>
    <link-entity name='systemuser' to='owninguser'>
       <filter type='and'>
          <condition attribute='lastname' operator='ne' value='Cannon' />
       </filter>
    </link-entity>
          </entity>
       </fetch>
       ";
    
    // Fetch the results.
    String result2 = service.Fetch(fetch2);

    Please check MSDN for more details
    http://msdn.microsoft.com/en-us/library/bb928434.aspx


    I hope this helps. If my response answered your question, please mark the response as an answer and also vote as helpful.
    Mubasher Sharif
    Check out my about.me profile!
    http://mubashersharif.blogspot.com
    Linked-In Profile
    Follow me on Twitter!


    Wednesday, June 20, 2012 10:37 AM
  • Thank you Sharif

    I will just try it and let you know if i get stuck some where.

    Wednesday, June 20, 2012 11:38 AM