locked
Filter condition in oData query RRS feed

  • Question

  • Hi,

    Can we filter a oData query with a dynamic value.

    Like to retrieve all the records of a logged in user.

    Logged in user value will be dynamic and can I use &$filter=+userName in the query?

    thanks for any help..

    Thursday, August 7, 2014 7:09 PM

Answers

  • first you need to get guid of loggin user and match with owner of the records

    var SystemUserId= Xrm.Page.context.getUserId();

    var serverUrl = Xrm.Page.context.getServerUrl();

    var ODataPath = serverUrl + “/XRMServices/2011/OrganizationData.svc/AccountSet?$filter=OwnerId/Id eq (guid'" + SystemUserId + "');


    ms crm

    Friday, August 8, 2014 6:26 AM
  • Hi,

     https://crm2011odatatool.codeplex.com/ Is a good tool to start creating odata queries.

    If you are looking for a solution similar to fetch xml, I am not aware of any.

    <filter type="and">
          <condition attribute="ownerid" operator="eq-userid" />
    </filter>

    Regards,

    Jithesh

    • Marked as answer by roxannaappleby Thursday, August 14, 2014 2:09 PM
    Friday, August 8, 2014 6:48 AM

All replies

  • first you need to get guid of loggin user and match with owner of the records

    var SystemUserId= Xrm.Page.context.getUserId();

    var serverUrl = Xrm.Page.context.getServerUrl();

    var ODataPath = serverUrl + “/XRMServices/2011/OrganizationData.svc/AccountSet?$filter=OwnerId/Id eq (guid'" + SystemUserId + "');


    ms crm

    Friday, August 8, 2014 6:26 AM
  • Hi,

     https://crm2011odatatool.codeplex.com/ Is a good tool to start creating odata queries.

    If you are looking for a solution similar to fetch xml, I am not aware of any.

    <filter type="and">
          <condition attribute="ownerid" operator="eq-userid" />
    </filter>

    Regards,

    Jithesh

    • Marked as answer by roxannaappleby Thursday, August 14, 2014 2:09 PM
    Friday, August 8, 2014 6:48 AM
  • But owner of the records will not be the 'logged-in user' in my application. The owner will be whoever enters the data into the record(like a task assigner).

    So I am not able to pull the records of logged in person by comparing with the getUserId() and OwnerId.

    What else can I do to pull the records?

    Thanks

    Tuesday, August 12, 2014 5:25 PM