1

Resolved

Retrieve Price List Item on CRM 2011 with QueryByAll

description

Hello,

Working with MsCRM 2011, I try to retrieve a price list item based on the productId. I tried with a "ByQueryAll" but when I try to set a filter, i recieved a "Bad Request" Error. Can you tell me what is wrong in my query ?

Thanks in advance.
CrmRestKit.ByQueryAll('ProductPriceLevel', ['PriceLevelId'], "ProductId eq '" + CrmRestKit.EntityReferenceFactory(productId[0].id) + "'", ", true)
            .fail(function (xhr, status, ethrow) { alert('Error: ' + status + ': ' + xhr.statusText + '.'); })
            .done(function (data, status, xhr) { alert("Ok"); } );

comments

thuld wrote Feb 13, 2014 at 9:29 AM

Hello ddu,

try this query:
var entity = 'ProductPriceLevel',
    cols = ['PriceLevelId'],
    // filter = "ProductId eq '" + CrmRestKit.EntityReferenceFactory(productId[0].id) + "'", ",
    filter = "ProductId/Id eq guid'" + productid + "'";

CrmRestKit
    .ByQueryAll(entity, cols , filter, true)
    .fail(function (xhr, status, ethrow) { alert('Error: ' + status + ': ' + xhr.statusText + '.'); })
    .done(function (data, status, xhr) { alert("Ok"); } );
For more details take a look at this msdn-article:

"You can use the $filter query option to filter for the value of an EntityReference attribute. For example, if you have the Id value for a SystemUser record, you can retrieve a list of all the account records that a user is assigned by using the following filter:"
/AccountSet?$filter=OwnerId/Id eq (guid'" + SystemUserId + "')
Daniel

wrote Feb 13, 2014 at 9:36 AM

ddu wrote Feb 13, 2014 at 10:54 AM

Hello Daniel,

Thanks for your answer. I will test this asap.