ms crm 2011 retrieve quote details with javascript

痞子三分冷 提交于 2019-12-14 03:57:35

问题


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!


回答1:


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



来源:https://stackoverflow.com/questions/14505442/ms-crm-2011-retrieve-quote-details-with-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!