WAS CHANGED Expression
The WAS CHANGED Expression is used in the conditional part of a rule (see Rule Condition) to check whether the value of a particular attribute of a business object or business object group has been changed compared to the value stored in the system. For example,
If Account.State WAS CHANGED Then …
The WAS CHANGED Expression can also be used to check if any attribute of the object has changed, for example:
If Account WAS CHANGED
The WAS CHANGED Expression can also check whether an attribute has been changed to a particular value, for example:
If Account.State WAS CHANGED TO 'Open' Then …
NOTE: When comparing new and old values of the attribute, the WAS CHANGED expression only checks whether the value has been changed compared to the value of the attribute in the last stable version of the business object – see the Evaluation of Rules Containing WAS CHANGED Expressions section).
Expressions that track changes in a list
The WAS CHANGED expression can be used for reference lists as well as for ordinary attributes. The WAS CHANGED expression for lists indicates whether there were any references changed or removed from the list. For example,
If Account.Transactions WAS CHANGED Then…
It is possible to identify more precisely how a reference list has been changed and perform actions based on the attribute values of objects that have been added or removed from the list. The WAS ADDED TO expression can be used to check whether any objects have been added to the list and the WAS REMOVED FROM expression can be used to check whether objects have been removed from the list. To refer to the objects that have been added or removed, the Added and Removed instance prefixes can be used respectively (see Instance Prefixes). For example,
If Transaction WAS ADDED TO Account.Transactions Then INCREASE Account.Balance BY AddedTransaction.Amount
If Transaction WAS REMOVED FROM Account.Transactions Then REDUCE Account.Balance BY RemovedTransaction.Amount
If the list itself hasn't been changed, but an element belonging to a list has been, then this situation can be checked using the combination of “FROM” and “WAS CHANGED” keywords, for example:
If Transaction FROM Account.Transactions WAS CHANGED Then …