Dear Developers and experts,
Good evening. I have a few conceptual questions on Global Defaults.
Why do we need Global Default?
From my old days of programming, Global Variables were a strict bad practice.
Surely there is a good reason to have it. Would be great to know.
What modules depend on these global defaults? How do they interact with each other?
Is it strictly necessary or is it time to re-visit?
Is it possible to encapsulate this within a company structure? So there is nothing Global.
Even though there might be a tendency to use a similar structure (example: Fiscal Year) within a 1-tenant-multi-company situation, still it would be good to isolate this concept a bit better.
Thanks again for clarifying.
You got the concept wrong!
“Global Defaults” aren’t “Global Variables”
Global Defaults, is a table in the database, where your application or any application can get a certain kind of values given a keyword!
It’s sounds much more a “KV DB” (Key Value Database).
The purpose of Global Defaults is to have a place, where you can store and get some information easy, but not in the code!
2 - Hard to say, but in a general manner every submitable doctype, make use of “Global Defaults”, to get some informations! And the permission system use it too, but to define “User Defaults”
3 - Being it a KV, you can model in your application, how you keys will look like, eg:
My Company:default_currency = “USD”
By default ERPNext use
“Company:company:default_currency” to get the information in the database, It sounds like “DocType:current_form_field:lookup_field”