List Or Library control - Filtering issue

Hi,

I have a List or Library control that I filter depending other field values. Fine, I can pass the control a CAML query and filter the control and works perfectly. However, when I try to reset the filter, even tho it seems to work, my grid shows this [object Object] warning at the bottom (see screenshot).

This is only shown if the control has been filtered before and I try to remove the filter:

var employeeID = fd.field('EmployeeIDInput').value; var grid = fd.control('EmployeesGrid'); grid.filter = (employeeID == "" || employeID == null) ? null : "<Eq><FieldRef Name='HREIPersonalNumber' /><Value Type='Text'>"+employeeID+"</Value></Eq>"; grid.refresh();

Hello, @Pablo_Medina,
I was also facing the same issue, Did you delete any columns from the list that associated with list or library control?
Can you share your console?

also make function for better understanding,

//call the function
fd.control('Contracts').ready().then(function (dt) {
filterDT(fd.control('EmployeesGrid'));
});
function filterDT(dt) {
    dt.filter = "<Eq><FieldRef Name='HREIPersonalNumber'/><Value Type='Text'>"
        + fd.field('EmployeeIDInput').value + "</Value></Eq>";
    dt.refresh();
}

Note: some times it is possible that filter is applied on the grid before it loads, so it is good practice to always filter once it loads.

Please let me know if you still have a problem.
Thanks.

3 Likes

Hey @harshp924,

nope I didnt manipulate the columns at all. Must be some kind of bug as it happens only after applying one filter and modifying it afterwards. The issue has not to do with the grid not loaded since its triggered way after.

This is the code of the filtering:

doFilterSlots = function(preferredLanguage, councilMemberId){
    var grid = fd.control('SlotsGrid');
    var filter = "<And>";
    
    // if preferred language is english, show only English appointments
    if(preferredLanguage == "EN"){
        filter +=  "<Eq><FieldRef Name='HREISlotPreferredLanguage' /><Value Type='Choice'>"+preferredLanguage+"</Value></Eq>";
    }
    // if preferred language is german, show both english and german appointments
    if(preferredLanguage == "DE"){
        filter += "<Or>";
        filter += "<Eq><FieldRef Name='HREISlotPreferredLanguage' /><Value Type='Choice'>EN</Value></Eq>";
        filter += "<Eq><FieldRef Name='HREISlotPreferredLanguage' /><Value Type='Choice'>DE</Value></Eq>";
        filter += "</Or>";
    }
    filter +=  "<Eq><FieldRef Name='HREIReserved' /><Value Type='Boolean'>0</Value></Eq>";
    // Plumsail forms component seems buggy with this query below :(
    if(councilMemberId !== null && councilMemberId !== "0"){
        filter += "<Eq><FieldRef Name='HREIWorkCouncilMember' LookupId='TRUE' /><Value Type='Lookup'>"+councilMemberId+"</Value></Eq>";
    }
    
    filter += "</And>";
    grid.filter = filter;
    grid.refresh();
}

And this is in the console:

after some tests, it seems the problem appears when you filter by more than 2 fields....

Hello @Pablo_Medina,

I couldn't reproduce this behavior on my side.

What type are EmployeeIDInput and HREIPersonalNumber fields?

Also, there is a typo in the code in employeeID variable name:

Do you mean you want to change the filter dynamically? What event triggers filtration?

Could you please provide more details about this. Are you getting incorrect records in the control or do you see the error in the console?

Hi @mnikitina ,

after revisiting this topic (ages later), i can confirm this is not a plumsail bug. The CAML query needs to be correct (facepalm), and i was trying to do more than 2 and/or conditions and needs exactly two child nodes.
See a related issue in stack overflow: sharepoint - CAMLQuery with multiple or conditions? - Stack Overflow

1 Like