locked
How to use SearchTerm with multiple fields and different operators? RRS feed

  • Question

  • Hi MDS-Experts,

    while trying to get data from MDS I get this error:

    System.ServiceModel.FaultException: The server was unable to process the request due to an internal error

    If I do not use the SearchTerm I get the error about exceeded items (System.ServiceModel.CommunicationException: The maximum message size quota for incoming messages (65536) has been exceeded), which is ok.

    This is what I am using:

    SPSecurity.RunWithElevatedPrivileges(delegate()
                    {
                        string url = ServiceConfiguration.MDSServiceUrl;
                        mdsProxy = MDSServices.CreateMdsProxy(url);
    EntityMembersGetRequest request = new EntityMembersGetRequest();
                        request.MembersGetCriteria = new EntityMembersGetCriteria();
                        request.MembersGetCriteria.ModelId = new Identifier() { Name = "SBMS" };
                        request.MembersGetCriteria.EntityId = new Identifier() { Name = "EmployeeLogin" };
                        request.MembersGetCriteria.VersionId = new Identifier() { Name = "VERSION_1" };
    
                        string _date = System.DateTime.Now.ToShortMDSDateString();
                        string sql = " [ValidTo] Is not NULL AND [System] = 'cms' AND [ValidTo] Is less than '" + _date + "'";
                        request.MembersGetCriteria.SearchTerm = sql;
    request.MembersGetCriteria.MemberReturnOption = MemberReturnOption.DataAndCounts; 
    
                        EntityMembersGetResponse response = mdsProxy.EntityMembersGet(request);
                        System.Collections.ObjectModel.Collection<Member> members = response.EntityMembers.Members;
    });

    So, it seems that the Syntax of the SearchTerm is not coorect. Any hints?

    [ValidTo] Is not NULL AND [System] = 'cms' AND [ValidTo] Is less than '09/19/2017'

    Update: It seems to be the Syntax of filtering Date columns. If I just use e.g. [System] = 'cms' AND [Login] ='4711' it is working.

    With Kind Regards, Ronny


    Tuesday, September 19, 2017 3:22 PM