How to add a field to show only logged user projects

Hi All.
In DocType Travel Reuqest I would like to display all the projects of the logged in user. I added a link field to Projects and I display all the projects in general. I am trying to filter only those of the logged in user using Link Filters but I can’t. Suggestions? How can I do it?

Thanks
Gigi

Hello :wave:,

You have to write the client script for that. I’m giving you some code put this code in the Travel Request Js file.

frappe.ui.form.on('Travel Request', {
    onload: function(frm) {
        frm.set_query('project', function() {
            return {
                filters: {
                    user: frappe.session.user
                }
            };
        });
    }
});

Here you can adjust the field name according to your Doctype fields and in the filters object you can write the filters logic which you want.
If you don’t know or face any problem please let me know.

Hi raj_007.

Thanks for your reply.

I couldn’t filter as I wanted via client script but you taught me something new that will be very useful :slight_smile:

To solve it I tried a new way: I deleted all permissions on projects for users and told the PM to assign the project to the various users via “assign”.

In this way users only see the projects that they have received as assignment.

Is this a correct way?

Bye and thanks.
Gigi