Property Setter / User Defaults

I’m trying to use the “defaults” table on the “User” field for some other custom script, but I see that by default, the “sb2” and “defaults” table on the User doctype is set to “hidden.” I’ve un-hidden these sections via the UI on our development server, but this didn’t create any fixtures to include in our custom app to export to our staging and production servers.

I’ve also tried manually creating property setters and exporting them, but they do not seem to be working; the User “defaults” and “sb2” sections are still hidden.

Is there some prohibition on using property setters on the Users doctype?

Here’s the fixture / property I’m trying to export from my app:

[
{
“default_value”: “1”,
“doc_type”: “User”,
“docstatus”: 0,
“doctype”: “Property Setter”,
“doctype_or_field”: “DocType”,
“field_name”: null,
“is_system_generated”: 0,
“modified”: “2024-06-15 17:37:00.512821”,
“module”: “Weigh Station”,
“name”: “User-sb2-sb2”,
“property”: “hidden”,
“property_type”: “Check”,
“row_name”: “sb2”,
“value”: “0”
},
{
“default_value”: “1”,
“doc_type”: “User”,
“docstatus”: 0,
“doctype”: “Property Setter”,
“doctype_or_field”: “DocType”,
“field_name”: null,
“is_system_generated”: 0,
“modified”: “2024-06-15 17:36:48.153752”,
“module”: “Weigh Station”,
“name”: “User-defaults-hidden”,
“property”: “hidden”,
“property_type”: “Check”,
“row_name”: “defaults”,
“value”: “0”
}
]

Since you selected the wrong option, you need to choose DocField and then select the field name.

You need to do the same thing for the section.

However, we do not recommend adding anything manually because these values will be automatically updated in transactions. They will also help restrict this user’s permissions on transactions containing these values.

Enter default values for fields (keys) and their values. If you add multiple values for a field, the first one will be used. These defaults also help set “match” permission rules. To see a list of fields, go to “Customize Form”.

1 Like

Thanks so much for this!

In general, what is the best practice for permanently assigning users to defaults for things other than Company? For example, let’s say that we have a user based at one branch, and we want that user to, by default, see only customers from a particular X (say, Customer Group, Territory, etc). Or we want them to, by default, see only Assets at one particular location, or when that user creates a new asset, it is by default created at one particular location.

I understand that this is essentially what the Session Defaults does, except those session defaults do not persist across sessions. What is the recommended “best practice” for having something like a “Session Default” that persists across sessions?

Setting session defaults is the best way to manage this. However, if you want a user to only access a specific branch and no other, you need to set user permissions. When user permissions are applied, it will ensure that only the designated branch is visible to the user, and no other branches will be shown.