web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to retrieve multiple records from an entity in crm using c#

(0) ShareShare
ReportReport
Posted on by 65

I am trying to retrieve records from case entity in crm.

How can I do that?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    prt33k Profile Picture
    6,907 on at
    RE: How to retrieve multiple records from an entity in crm using c#

    Hi Samhita,

    You need to write a plugin/custom action/workflow to use C# to extract multiple record.

    However in what sceanrio you want to extract record - Are you trying yo update the case or you just want to show the record in some Grid?

  • Samhitha Profile Picture
    65 on at
    RE: How to retrieve multiple records from an entity in crm using c#

    first i need to show in grid, and then i will use that to update the record

  • Verified answer
    Community Member Profile Picture
    on at
    RE: How to retrieve multiple records from an entity in crm using c#

    Hi! 

    internal static List<Entity> GetAllContacts(IOrganizationService service)
            {
                var pageNumber = 1;
                var pagingCookie = string.Empty;
                var result = new List<Entity>();
                EntityCollection resp;
                do
                {
                    var query = new QueryExpression("contact") { ColumnSet = new ColumnSet("emailaddress1", "lastname") };
                    #region Add conditions to query
                    query.Criteria.AddCondition(new ConditionExpression("statecode", ConditionOperator.Equal, 0));
                    query.Criteria.AddCondition(new ConditionExpression("emailaddress1", ConditionOperator.NotNull));
                    query.Criteria.FilterOperator = LogicalOperator.And;
                    #endregion
                    query.PageInfo = new PagingInfo
                    {
                        PageNumber = 1,
                        Count = 5000
                    };
                    if (pageNumber != 1)
                    {
                        query.PageInfo.PageNumber = pageNumber;
                        query.PageInfo.PagingCookie = pagingCookie;
                    }
                    resp = service.RetrieveMultiple(query);
                    if (resp.MoreRecords)
                    {
                        pageNumber++;
                        pagingCookie = resp.PagingCookie;
                    }
                    result.AddRange(resp.Entities.ToList());
                } while (resp.MoreRecords);
                return result.ToList();
            }

    Hope this helps

     

    Vlad

    dynamicalabs.com

    Disclaimer: Any post on this page provided "as is" without warranty of any kind and is for educational and information purposes only. We disclaim any liability arising from any reliance placed on any post

  • Samhitha Profile Picture
    65 on at
    RE: How to retrieve multiple records from an entity in crm using c#

    Thanks for your answer, but i am trying to do without organization service i.e by using web api

  • Verified answer
    VermaNitin Profile Picture
    455 on at
    RE: How to retrieve multiple records from an entity in crm using c#

    Hi Samhitha,

    It seems that you are trying to show records in a custom HTML (grid).

    The best approach depends on your CRM version, you can use SOAP/WebApi depending on your CRM version to fetch the records and then modify the response to render in the grid.

    Hope it helps!

    Many thanks,

    Nitin Verma

  • Samhitha Profile Picture
    65 on at
    RE: How to retrieve multiple records from an entity in crm using c#

    thank you

  • Suggested answer
    Tanmay G Profile Picture
    10 on at
    RE: How to retrieve multiple records from an entity in crm using c#

    Hi Samhitha,

    Using Xrm.WebApi.retrieveMultipleRecords in JScript you can fetch the case entity records in CRM. You can refer to below MSDN link which explains the same with an example.

    https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/xrm-webapi/retrievemultiplerecords

    Hope this help!

    Thanks and Regards,

    Tanmay.

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#1
UllrSki Profile Picture

UllrSki 2

#3
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans