Skip to main content
Jenn Sherbrook (CNL) ha fatto una domanda in #Data Management
Is it possible to know what field(s) were changed in and before update trigger? I have an object that has about 12 fields and I'm trying to allow only two fields to be updated on the object. Is there an easy way to check to see which fields caused a trigger to fire?
3 risposte
  1. 7 dic 2011, 15:04
    In validation rules you can use ISCHANGED() function

     

    ISCHANGED

    Description: Compares the value of a field to the previous value and returns TRUE if the values are different. If the values are the same, this function returns FALSE. Use: ISCHANGED( field ) and replace field with the name of the field you want to compare. Validation Rule Example: The following validation rule prevents users from changing an opportunity name after it has been created: NOT(ISCHANGED(Name)).

    NOT(AND(ISCHANGED(Priority), ISPICKVAL(Priority, “Low”))) is a validation rule that ensures if a user changes the Priority of a case, the new priority cannot be “Low.”

    NOT(AND(ISCHANGED(CloseDate), ​OR(MONTH(CloseDate) <> MONTH(TODAY()), ​YEAR(CloseDate) <> YEAR(TODAY())),$

    Profile.Name

    <> "Sales Manager")) is a validation rule that prevents a user from changing the Close Date of an opportunity to a date outside of the current month and year unless that user has the “Sales Manager” profile. Note

    _img src="

    https://help.salesforce.com/img/help/helpNote_icon.gif

    " /_$Profile merge fields are only available in Enterprise, Unlimited, and Developer Editions.

    Tips:

    • This function is available only in:

      • Assignment rules
      • Validation rules
      • Field updates
      • Workflow rules if the trigger type is set to Every time a record is created or edited.
    • Use the NOT function to reverse the return values of TRUE and FALSE.
    • This function returns FALSE when evaluating any field on a newly created record.
    • If a text field was previously blank, this function returns TRUE when it contains any value.
    • For number, percent, or currency fields, this function returns TRUE when:

      • The field was blank and now contains any value
      • The field was zero and now is blank
      • The field was zero and now contains any other value
0/9000