locked
Fetch all Open cases RRS feed

  • Question

  • please provide me C# code  to Fetch all open cases if there exist

    Wednesday, September 16, 2009 5:10 AM

Answers

  • Hi,

    Try the code below.  I haven't compiled it but I think it should work.

    // Set up the CRM Service.
    CrmAuthenticationToken token = new CrmAuthenticationToken();
    // You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory authentication.
    token.AuthenticationType = 0; 
    token.OrganizationName = "AdventureWorksCycle";
     
    CrmService service = new CrmService();
    service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
    service.CrmAuthenticationTokenValue = token;
    service.Credentials = System.Net.CredentialCache.DefaultCredentials;


    // Create the QueryExpression object.
    QueryExpression query = new QueryExpression();

    // Set the properties of the QueryExpression object.
    query.EntityName = EntityName.incident.ToString();
    query.ColumnSet = new AllColumns();


    // Retrieve the contacts.
    BusinessEntityCollection becIncidents = service.RetrieveMultiple(query);

    Hassan.

    Hassan Hussain | http://hassanhussain.wordpress.com/ | http://www.mscrmvirtualusergroup.com/
    • Proposed as answer by Hassan Hussain Wednesday, September 16, 2009 5:40 AM
    • Marked as answer by Donna EdwardsMVP Thursday, September 17, 2009 1:36 PM
    Wednesday, September 16, 2009 5:40 AM
  • In addition to Hassan's answer I suggest to add another one filter by statecode:

    query.Criteria.AddCondition(new ConditionExpression("statecode", ConditionOperator.Equal, IncidentState.Active.ToString()));


    Truth is opened the prepared mind My blog - http://a33ik.blogspot.com
    Wednesday, September 16, 2009 7:33 AM
    Moderator

All replies

  • Hi,

    Try the code below.  I haven't compiled it but I think it should work.

    // Set up the CRM Service.
    CrmAuthenticationToken token = new CrmAuthenticationToken();
    // You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory authentication.
    token.AuthenticationType = 0; 
    token.OrganizationName = "AdventureWorksCycle";
     
    CrmService service = new CrmService();
    service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
    service.CrmAuthenticationTokenValue = token;
    service.Credentials = System.Net.CredentialCache.DefaultCredentials;


    // Create the QueryExpression object.
    QueryExpression query = new QueryExpression();

    // Set the properties of the QueryExpression object.
    query.EntityName = EntityName.incident.ToString();
    query.ColumnSet = new AllColumns();


    // Retrieve the contacts.
    BusinessEntityCollection becIncidents = service.RetrieveMultiple(query);

    Hassan.

    Hassan Hussain | http://hassanhussain.wordpress.com/ | http://www.mscrmvirtualusergroup.com/
    • Proposed as answer by Hassan Hussain Wednesday, September 16, 2009 5:40 AM
    • Marked as answer by Donna EdwardsMVP Thursday, September 17, 2009 1:36 PM
    Wednesday, September 16, 2009 5:40 AM
  • In addition to Hassan's answer I suggest to add another one filter by statecode:

    query.Criteria.AddCondition(new ConditionExpression("statecode", ConditionOperator.Equal, IncidentState.Active.ToString()));


    Truth is opened the prepared mind My blog - http://a33ik.blogspot.com
    Wednesday, September 16, 2009 7:33 AM
    Moderator