locked
how to fetch perticular contact accounts and cases RRS feed

  • Question

  • how to fetch particular contact accounts and cases  for portal how to contact id didn't understanding please help me
    Wednesday, September 2, 2015 4:54 AM

All replies

  • ofter authentication how to get authentication user accounts and casses this is very helpfull for me please help me
    Tuesday, September 1, 2015 8:52 AM
  • 1. place connection string in your web.config file like:

    <connectionStrings>
        <add name="CrmConnectionStr" connectionString="Server=https://yourCrmOrgServerUrl/;Username=CrmLoginUserName;Password=CrmLoginPassword;" />
      </connectionStrings>

    2. Right click the project and add references to the following dll's

    • Microsoft.Xrm.Sdk.dll
    • Microsoft.Xrm.Client.dll
    • System.Runtime.Serialization.dll
    • System.Data.Services.dll

    3. get account data in c# code like:

    using (OrganizationService service = new OrganizationService("CrmConnectionStr")) { //Get Active Accounts string RetrieveProductfetchXml = @" <fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'> <entity name='account'> <attribute name='name' /> <attribute name='accountid' /> <order attribute='name' descending='false' />

      <filter type='and'>
                                  <condition attribute='statecode' operator='eq' value='0' />
                                </filter>   

    </entity> </fetch>"; RetrieveMultipleRequest fetchRequest = new RetrieveMultipleRequest(); fetchRequest.Query = new FetchExpression(RetrieveProductfetchXml); RetrieveMultipleResponse resp = (RetrieveMultipleResponse)service.Execute(fetchRequest); if (resp != null && resp.EntityCollection != null) { EntityCollection collection = resp.EntityCollection; if (collection != null && collection.Entities.Count > 0) { foreach (Entity ent in collection.Entities) { if (ent != null) { AccouhntId= ent.Id; if (ent.Contains("name") && ent["name"] != null) AccountName = ent["name"].ToString();

    -----------------------------

    -----------------------------

    ----------------------------- } } } } }


    Wednesday, September 2, 2015 6:29 AM