简体   繁体   中英

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!

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM