[Vtigercrm-developers] Use of vtiger_def_org_field?

Alan Lord alanslists at gmail.com
Fri Mar 10 11:02:15 GMT 2023


I had an odd thing happen recently...

This is on a vtiger 7.4.0 system which had been migrated from a vtiger 
5.x system. At some point in the past, probably when it was v5,  the 
customer had hidden the secondary email field in the Accounts module 
(fieldname = email2) - using the layout editor.

On Wednesday we needed to use that field again so using the layout 
editor I re-activiated the field. As an admin, all was fine but 
non-admin users couldn't see the field. Checking the Profiles, the field 
was hidden (black) in the non-admin profiles so I made it green 
(read/write) and saved the profile. The field still wasn't visible...

Looking in the database the definition of the two fields 
(vtiger_field.fieldid 9 & 11) they were pretty much the same 
configuration (i.e. all the important values like "presence" etc.). And 
in vtiger_profile2field they were both configured the same too (for all 
Profiles)!

I scratched my head...

This morning I decided to take a better look around the database and 
discovered the visible value was different between fieldid 9 & 11 in the 
vtiger_def_org_field table. Changing the value fixed the problem and the 
field was now visible.

This isn't something I've seen before - in well over a decade - and to 
be honest I've never really needed to delve into the 
vtiger_def_org_field table. So I was just wondering if someone can tell 
me what it is really for?

Grepping the code I can see values are retrieved in CRMEntity, and in a 
few other places, but it isn't really clear what it is for and why it 
wasn't updated correctly when I changed the visibility of a field using 
the normal Admin UI tools.

There are not many places where it is written to...

In the Profiles Record Model:

https://code.vtiger.com/vtiger/vtigercrm/-/blob/master/modules/Settings/Profiles/models/Record.php#L873

This method looks a bit wrong to me. It's only got an INSERT statement. 
Shouldn't this really be an "INSERT ... ON DUPLICATE KEY UPDATE " 
instead? Or else it will never get updated surely?

Same here:
https://code.vtiger.com/vtiger/vtigercrm/-/blob/master/include/utils/utils.php#L679

There is no way to update. A row in this table would need to be deleted 
and then re-created.


TIA

Al



More information about the vtigercrm-developers mailing list