locked
How to findout orders under account entity through webservice? RRS feed

  • Question

  • Dear All,

    I am using crm 4.0.  Dveloping a portal using CRM 4.0 webservice.

    I want to find out whether orders exists under the account or not. if orders found, how many fulfilled orders having under the Account  ?

    And also how many "existing products " having under the Order ? Kindly give me idea.

    Thanks in Advance,

    BR,
    NAG.
    • Edited by crmpnk1 Wednesday, January 27, 2010 12:46 PM s
    Wednesday, January 27, 2010 12:37 PM

Answers

  • ohhh sorry, copy paste :D
    its actually guid, not string.

    query.Values = new object[] {new Guid("Account ID Here")};
    Wednesday, January 27, 2010 1:34 PM

All replies

  • if you have the account id, you can get all the orders by using QueryByAttribute

    // Create a column set holding the names of the columns to be retrieved.
    ColumnSet cols = new ColumnSet();
    cols.Attributes = new string [] {"description", "statecode"}; // enter the name of the columns here from teh order entity.

    // Create the query object.
    QueryByAttribute query = new QueryByAttribute();
    query.ColumnSet = cols;
    query.EntityName = EntityName.salesorder.ToString();

    // The query will retrieve all accounts whose address1_city is Sammamish.
    query.Attributes = new string [] {"customerid"};
    query.Values = new string [] {new Guid("Account ID Here")};

    // Execute the retrieval.
    BusinessEntityCollection retrieved = service.RetrieveMultiple(query);

    // the above quote will return all the orders for the account.

    // use the foreach loop to go through all the orders.

    Wednesday, January 27, 2010 12:46 PM
  • Hi Ali,

    Thanks for the reply. I am getting error in the following

    line query.Values = new string [] {new Guid("Account ID Here")};

    Error: Value of string can'be converted into string.

    Thanks in advance,

    NAG.
    Wednesday, January 27, 2010 1:12 PM
  • ohhh sorry, copy paste :D
    its actually guid, not string.

    query.Values = new object[] {new Guid("Account ID Here")};
    Wednesday, January 27, 2010 1:34 PM
  • Thanks Ali. It's working..
    Thursday, January 28, 2010 5:55 AM