locked
CRM 2016 Online: Need help retrieving POAA records using OdataQuery in webresource RRS feed

  • Question

  • CRM 2016 Online: Need help retrieving POAA records using OdataQuery in webresource.

    We have a scenario where we need to query/access 'PrincipalObjectAttributeAccess' table from Webresource. Can any one help to access /retrieving data form POAA.

    I am getting error message:"{\r\n\"error\": {\r\n\"code\": \"\", \"message\": {\r\n\"lang\": \"en-US\", \"value\": \"Operator 'eq' incompatible with operand types 'Microsoft.Crm.Metadata.ComplexTypeInstance`1[[Microsoft.Xrm.Sdk.EntityReference, Microsoft.Xrm.Sdk, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]' and 'System.Guid' at position 78.\"\r\n}\r\n}\r\n}" when it is loaded on the form.

    Below is the value passed to the system during the run time

    ODataPath: "https://XXXXXX.crm.dynamics.com/XRMServices/2011/OrganizationData.svc/PrincipalObjectAttributeAccessSet?$select=ReadAccess, PrincipalId,PrincipalObjectAttributeAccessId&$filter=AttributeId eq (guid'{CF9E1FA3-2EFF-4B9A-8850-87197AE7DE98}') and PrincipalId eq (guid'{D2890D2C-A27E-E611-812E-C4346BADE530}') and ObjectId eq (guid'{649734E5-72EF-E511-8127-C4346BB588C8}')"

    function FindLicenseduser()
    {
    
        var ServerUrl = Xrm.Page.context.getClientUrl();
        var UserId = Xrm.Page.context.getUserId();
        var OpptyId = Xrm.Page.data.entity.getId();
        var ODataPath = ServerUrl + "/XRMServices/2011/OrganizationData.svc/";
        // AttributeID - CF9E1FA3-2EFF-4B9A-8850-87197AE7DE98 
        var AttributeId = "{CF9E1FA3-2EFF-4B9A-8850-87197AE7DE98}";
        var OdataQuery = "PrincipalObjectAttributeAccessSet?$select=ReadAccess, PrincipalId,PrincipalObjectAttributeAccessId&$filter=AttributeId eq (guid'" + AttributeId + "') and PrincipalId eq (guid'" + UserId + "') and ObjectId eq (guid'" + OpptyId + "')";
        ODataPath = ODataPath + OdataQuery;
        var retrieveUserReq = new XMLHttpRequest();
        retrieveUserReq.open("GET", ODataPath, true);
    
        retrieveUserReq.setRequestHeader("Accept", "application/json");
        retrieveUserReq.setRequestHeader("Content-Type", "application/json; charset=utf-8");
        retrieveUserReq.onreadystatechange = function () {
            retrieveUserReqCallBack(this);
        };
        retrieveUserReq.send();
    
    }
    
    function retrieveUserReqCallBack(retrieveUserReq)
    {
        if (retrieveUserReq.readyState == 4 /* complete */) {
    
            if (retrieveUserReq.status == 200) {
                var retrievedUserId = this.parent.JSON.parse(retrieveUserReq.responseText).d;
               
                alert(retrievedUserId.PrincipalId);
    
            }
    
            else {
                showMessage("retrieveAccountReqCallBack function failure END");
            }
        }
    }


    Madhu M.

    Wednesday, November 2, 2016 7:44 PM