Filter List by Selected User

Hi, I have two lists
1.- Onboarding Users
2.- Tasks

In the first list i have all the fields about oboarding, the second list containg Tasks for each New onboarding User, The onboarding user can have several items.

When a user clicks on any user and the display form is shown, I want to show the list with the tasks that that user has assigned.
I'm ussing the List - Library componente.
But I can't manage to filter by selected user.

Dear @eterrazas,
You can find this article on filtering List or Library here - Filter List or Library by CAML in a SharePoint form — SharePoint forms

Here's the code that you can try for filtering by current user:

fd.spRendered(function() {
    var dt = fd.control('SPDataTable1');
    dt.ready(function() {

    function filterDT(){
           dt.filter = "<Eq><FieldRef Name='EmployeeName' /><Value Type='User'>" + user['Title'] + "</Value></Eq>"; 

I tried with the code but it does not display the filter.

The filter that I need is not for the logged in user, it is for the selected user. in this case Employee Name.

I try with this code and it work:

function filterDT(){
        dt.filter = "<Contains><FieldRef Name='EmployeeName'/><Value Type='Text'>"
            + fd.field('Title').value + "</Value></Contains>";

thanks for your help

1 Like