How do I make a field required for some users but not everyone?

Hello, 

I am looking to create some customized modules utilizing the role based views. Can I make a field required for a select team but not required for other teams or users? 

If this is possible - how do I make this happen? Thanks for all of the help! 

  • You can not, out of the box, make a field required for a specific users. But you can do this job by implementing a custom sugarLogic formula and Dependency SetRequired.

    Save the attached file in custom/include/Expressions/Expression/Boolean/

    Then create a SetRequired Dependency whch has as trigger:

    isUserInList(createList("user_1", "user_2"))

    Go to Admin -> Repair and execute the actions:

    • Rebuild Sugar Logic Functions
    • Quick Repair and Rebuild
    • Rebuild JS Grouping Files
    • Clear Additional Cache

    Regards

    André Lopes
    Lampada Global
    Skype: andre.lampada
  • Hi Katie DelValle,

    I noticed you mentioned Role-Based Views. The solutions offered above do not use Role-based Views, but they provide for a scenario that Role-Based Views cannot support: Being able to see the field when it is not required.

    Field requirement validation happens in the layout, so anything that hides a required field (calculated dependency or Role-based views, for example) will make the field not required when it is hidden.

    The only way to have a field visible but conditionally required is to use a custom code solution like those provided above.

    I hope this helps!