Douglas Santos
Douglas Santos

Reputation: 153

CRM Dynamics Web API - Get Quotes

I currently have a code that could net the web and adapted to pick up some record of using crm Quote ID as a parameter. It usually works but now I need to get a quote using the Quote Number but I don't know how.

I am using IOrganizationService.Retrieve Method.

Can anyone help?

Upvotes: 1

Views: 356

Answers (1)

Guido Preite
Guido Preite

Reputation: 15128

If your code retrieves the Id of the Quote (meaning the unique GUID) probably currently it does something like:

Entity quote = service.Retrieve("quote", quoteId, new ColumnSet(true);

If you need to retrieve using another field you need to use a QueryExpression in combination with a RetrieveMultiple, something like:

QueryExpression query = new QueryExpression("quote");
query.ColumnSet = new ColumnSet(true);
query.Criteria = new FilterExpression();
query.Criteria.AddCondition("quotenumber",ConditionOperator.Equals, myQuoteNumber);
EntityCollection quotes = service.RetrieveMultiple(query);
if (quotes.Entities.Count == 1) {
Entity quote = quotes.Entities[0];
} else {
// quote not found or multiple quotes found
}

Upvotes: 3

Related Questions