Print      Open PDF Version of Online Help


Previous Topic

Next Topic

PRE

The PRE function in Expression Builder returns the previous value of the specified field when the field value is modified but before the value is updated in the database.

CAUTION: It is strongly recommended that you do not use the PRE function with workflow rules containing a Wait action, because the Wait action affects the PRE function. Any actions following the Wait action are not performed until the specified wait period has expired. The remaining actions are performed in a different batch operation than the operation where the rule was originally triggered, and the values of the fields on the record prior to the action that triggered the workflow rule are not preserved. Therefore, the previous value and the current value of the field are always considered to be the same.

Syntax

PRE('<fieldname>')

Result Type

String

Arguments

The following table describes the arguments for the function.

Argument

Description

fieldname

The name of the field that was modified.

NOTE: The language-independent field names and the field-name syntax used in any example expressions in this topic are the field names and the field-name syntax that were used in Expression Builder in releases earlier than Release 29 Service Pack 1. These examples are still valid. However, if you select the corresponding fields for an expression from the Fields list in Expression Builder in Release 29 Service Pack 1 or later, then the field names and the field-name syntax will be different from those shown in the examples. It is recommended that you always select the fields for your expressions from the Fields list in Expression Builder, so that the field names and the field-name syntax are always correct. For more information about the field names and the field-name syntax in expressions, see About Expressions.

The following considerations apply when using the PRE function:

  • In conditional expressions, such as workflow conditions and validation statements, when you use the PRE function to retrieve the previous value of a field, remember that the initial value of the field can be blank (that is, a null value). If the initial value is null, any comparison with a non-null value results in unpredictable behavior. To ensure that conditional expressions are evaluated correctly in such cases, use the PRE function with the IfNull function as shown in this example:

    IfNull([<FieldName>], "Invalid") <> IfNull(PRE('<FieldName>'), "Invalid")

    In this example, the text string Invalid is used to replace the null value, but you can use any string that you want, provided that the string does not exist as a value in the field that is being examined.

  • If the PRE function is used in a workflow rule or action that is invoked after a Wait action, the function does not return the previous value of a field. However, you might have a business process that requires such comparisons. In such cases, you can use a workflow rule with the Before Modified Record Saved trigger event to store the previous value of a field in any unused field on the record type. You can then use the stored field value for any comparisons you require in workflow rules that have the Wait action.

    When you create the workflow rule to store the previous value of a field in an unused field on the record type, remember that the previous value of the original field might be blank (that is, a null value). Therefore, you must use an expression such as the following to store a default value if a null value is encountered:

    IfNull([<FieldName>], "Invalid")

    In this example, the text string Invalid is the default value that is used to replace a null value, but you can use any string you want, provided that the string does not exist as a value in the original field.

Example of Creating a Workflow Rule That Sends an Email to the Previous Owner of an Account Record

The following is an example of how to create a workflow rule that sends an email to the previous owner of an account record when the owner of the record is changed.

To create a workflow rule that sends an email to the previous owner of an account record

  1. Create a workflow rule for the Account record type with the When Modified Record Saved trigger event.
  2. Save the workflow rule.
  3. Create an Add an Email action on the workflow rule.
  4. On the workflow action, do the following:
    1. In the To field, select Specific Email Address.
    2. In the To field expression text box, add the following expression:

      JoinFieldValue('<User>', IfNull(PRE('<OwnerId>'), "admin@mycompany.com"),'<EMailAddr>')

    3. Add the necessary text in the subject and body of the email.
    4. Save the workflow action.

Related Topics

See the following topics for related Expression Builder information:


Published 6/21/2021 Copyright © 2005, 2021, Oracle and/or its affiliates. Legal Notices.