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

  1. Navigate to the Details Page Layouts section of the Deal Registration object.

  2. Select Default Custom Layout.

    The Details Layout page appears.
  3. Click the Partner Justification field.

    The Edit UI Properties page appears.
  4. 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.
  5. Click the Expression Builder icon.

    The Advanced Expression page appears.
  6. 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 false
    Note: 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.
  7. Click OK.

    The Edit UI Properties page appears with the expression next to the Required property.

  8. Click Save and Close.

  9. On the Details Layout page, click Done.

    The Partner Justification field now appears as a required field in the edited layout for partner users.