Set the Required Field Property
You can make a field conditionally required using the Required property. For example, consider a custom object named Deal Registration that contains a Partner Justification field.
Your requirement is that the Partner Justification field always appears as a mandatory field, but only for partner users.
The following example illustrates how to set the Partner Justification custom field as conditionally required for partner users.
Make a Field Conditionally Required
- 
               Navigate to the Details Page Layouts section of the Deal Registration object. 
- 
               Select Default Custom Layout. The Details Layout page appears.
- 
               Click the Partner Justification field. The Edit UI Properties page appears.
- 
               In the Layout Properties section, select Expression from the drop-down list of the Required property. The Expression Builder icon appears next to the property.
- 
               Click the Expression Builder icon. The Advanced Expression page appears.
- 
               Enter the following expression in the Edit Script section: def secCtx = adf.context.getSecurityContext() if (secCtx.isUserInRole('ORA_ZPM_PARTNER_SALES_REPRESENTATIVE_JOB')) return true else return falseNote:Field properties are evaluated many times while rendering a page. This means that any expression you enter here could impact performance. In general, when entering an expression to make a field conditionally required or updatable, avoid using object functions and don't set any object attribute values. 
- 
               Click OK. The Edit UI Properties page appears with the expression next to the Required property. 
- 
               Click Save and Close. 
- 
               On the Details Layout page, click Done. The Partner Justification field now appears as a required field in the edited layout for partner users.