currentUserField() and core User fields

Hello,

I was wondering if one of you can answer this question : why core user fields are not available for the currentUserField() formula ?

Is there a logical reason I am missing that explains this ?

Because, while digging in the code, we understand that one property was missing for core fields (calculation_visible) but it seems that other vardefs properties are involved.

For instance, we were looking on an easy way to set a field as readonly if you are not an admin. The admin field is a core user field. We are able to customize the sugarfield_is_admin.php file and include 

$dictionary['User']['fields']['is_admin']['calculation_visible']=true;
But another property is missing for this field : $def['studio']['related'].
Because is_admin is a important field, we don't want to play with the studio.related property that we currently don't understand. Is someone aware about this vardefs property ?
Many thanks for your help.
Fred

the code I am talking about : 
  • include/Expressions/Expression/Generic/CurrentUserFieldExpression.php
  • modules/ExpressionEngine/formulaHelper.php with cleanFields function used from getValidUserFields function
Parents
  • Hello  , 

      approach is spot on, and it will set your field to read-only at a UI level. 

    However, if you're looking for a more robust solution, I would suggest creating a Role that sets specific fields to read-only and adding the relevant users to that role. This can be done without any code customization and restricts editing both at the UI and API levels.

    Let us know your thoughts!

    Cheers,
    André

Reply
  • Hello  , 

      approach is spot on, and it will set your field to read-only at a UI level. 

    However, if you're looking for a more robust solution, I would suggest creating a Role that sets specific fields to read-only and adding the relevant users to that role. This can be done without any code customization and restricts editing both at the UI and API levels.

    Let us know your thoughts!

    Cheers,
    André

Children
No Data