Need help with oData "$select/$filter" statement RRS feed

  • Question

  • Hello All,

    I am using oData to get some information related to some entities. But I am having trouble creating a compound $filter statement.

    I want to find all records "CheckRegister" records that belong to the current Contact where the "Amount" is greater than 5.

    Here is a snippet that I am trying to use. but when I make the call, my result set is null.

    Where am I going wrong?

    var memberId = Xrm.Page.data.entity.getId().replace("{","").replace("}","");
    var filter = "?$select=new_registerId,new_registerdate, new_registeramount"
    +"&$filter=new_OwningContactId/Id eq (guid'" + memberId + "')" 
    +" and new_registeramount ge 5"; // <-- problem clause
    var entries = retrieveRecord("new_registerSet", filter);
    // retrieveRecord is a function that gets all matching records.
    // It is working and isn't a problem here.

    if I leave out the "and new_registeramount ge 5" part, everything works well. While testing/troubleshooting, I find that I have the same problem with other entities, so I suspect that it is a problem with my syntax.

    Any suggestions on where I'm going wrong?



    Thursday, March 8, 2012 2:06 AM


  • What Data Type is 'new_registeramount'?  If, for instance, it is a Currency or Picklist type, you'll need to access the Value property, thus:

    $filter=new_OwningContactId/Id eq (guid'" + memberId + "') and new_registeramount/Value ge 5

    --pogo (pat) @ pogo69.wordpress.com

    • Marked as answer by DadKind Thursday, March 8, 2012 6:47 PM
    Thursday, March 8, 2012 4:09 AM

All replies