Linq query to retrieve active quotes RRS feed

  • Question

  • Have a winapp that I am connecting to my CRM system, I am trying to fill a combobox with all currently active quote names, but if I look at the quote.statuscode its an option set, so how can I do this?

     public void GetAllQuotes(ServerConnection.Configuration serverConfig, TextBox obj_txt_Status, ComboBox cmb_box)
                    // Connect to the Organization service. 
                    // The using statement assures that the service proxy will be properly disposed.
                    using (_serviceProxy = ServerConnection.GetOrganizationProxy(serverConfig))
                        _service = (IOrganizationService)_serviceProxy;
                        ServiceContext svcContexts = new ServiceContext(_service);
                        var quotes = from q in svcContexts.QuoteSet
                                     //join a in svcContexts.AccountSet on c.ParentCustomerId.Id equals a.AccountId
                                     //where (q.Name == "QUO-17583-G9D9")
                                     where (q.Name.Contains("QUO-"))
                                     //&& (q.StatusCode.Value == "active")
                                     orderby q.Name
                                    select new Quote
                                        Name = q.Name,                                   
                                        StatusCode = q.StatusCode
                        foreach (Quote quote in quotes)
                // Catch any service fault exceptions that Microsoft Dynamics CRM throws.
                catch (FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault>)
                    // You can handle an exception here or pass it back to the calling method.


    Thursday, October 1, 2015 1:42 PM

All replies

  • Hello,

    Have you tried something like

    q.StateCode.Value == 1


    Dynamics CRM MVP
    My blog

    Thursday, October 1, 2015 2:39 PM
  • I can set the integer value, just wondering if I could set it to the text value i.e. "Active" if so how?


    Thursday, October 1, 2015 3:28 PM