Thomas
Thomas

Reputation: 101

ms crm 2011 retrieve quote details with javascript

How can I retrieve all products (= quote details) of a quote by javascript?

I have tried following code, but that doesn't work:

id = quoteid
var options = "$select=ProductId&$filter=QuoteId eq (guid'"+ id + "'";
SDK.REST.retrieveMultipleRecords("QuoteDetail", options, ebcont.crm.quote._successQuoteDetailMultiRetrieve, function(error) {alert(error.message);}, ebcont.crm.quote._multiRetrieveQuoteComplete);

I always get following message:

 Error: 400: Bad Request: operator 'eq' is no compatible with operatortyp 'Microsoft.Crm.Metadata.ComplexTypeInstance'1 ... and 'System.Guid'

Does somebody have any idea what is wrong?

Thanks in advance!

Upvotes: 2

Views: 3542

Answers (1)

Daryl
Daryl

Reputation: 18895

Try adding id to QuoteId:

id = quoteid
var options = "$select=ProductId&$filter=QuoteId/Id eq (guid'"+ id + "'";
SDK.REST.retrieveMultipleRecords("QuoteDetail", options, ebcont.crm.quote._successQuoteDetailMultiRetrieve, function(error) {alert(error.message);}, ebcont.crm.quote._multiRetrieveQuoteComplete);

It is case sensitive so be careful about that as well. I'd recommend using the FetchXmlBuilder plugin for the XrmToolBox to test REST oData calls first. It has an option to view the rest url. As long as your javascript generates the exact url, you should be good.

Update 1

With the new (in 2016) CRM WebAPI endpoint I'd also recommend Jason Lattimer's CRM Rest Builder: https://github.com/jlattimer/CRMRESTBuilder/releases

Upvotes: 5

Related Questions