Hello developers, how can we set a default company for a user (without using session default)?
We can use session default, but the permission seems to be lost after logging out. How can we implement a persistent default company for a user …?
Hello developers, how can we set a default company for a user (without using session default)?
We can use session default, but the permission seems to be lost after logging out. How can we implement a persistent default company for a user …?
Thank you @ahsantareen for your response.
My user has access to all companies, so we haven’t set up any user permissions. I just want to set a default company.
Can i know how you are creating user ? Are you creating user directly from user screen or by using Employee screen. If you are using Employee screen then from here you can select default company for employee and after creating user for this employee automatically it will create a User Permission record so that user can see his comapny details only
I’m creating it directly from the User screen. I don’t want to set User Permission. I just need to set the default company for a particular user.
By using Global Defaults you can set default Company for all Users.
Just Type Global Defaults in Awesome Bar and open it and use the Default Company to set Default Company for all the Users.
Hi
It looks like session default is the last resort as you dont want to apply user permission.
Custom solution may help but require code.
A company is already set in Global Defaults. In my case, I have four companies in the cloud, and I want to set the second company as the default company for my user.
You can set a default Company for a user by creating a DefaultValue
record like this:
frappe.defaults.set_user_default("company", company_name, user_name)
Note: Please Fetch Users from User doctype and use its name and similarly do for company you want.