How to update a field based on change in another field?
How to update a field when another field is updated?
The answer to this question is.
- On Field Update Set n user property. (This is the answer interviewer is looking for though)
You can write script on SetFieldValue event of buscomp to update the target field. But the problem with this solution is if user UNDO the record then your script won’t revert back the changes that it has done.
One more solution can be to check in SetFieldValue event if that field is being updated through global flag and then on WriteEvent of buscomp execute your script only if that flag is set to true. But again you will have to set global flag to false may be Delete event (this is fired when user undo the record).
These solutions by scripting are really cumbersome. So we generally use On Field Update set n User property for this kind of requirement.
On Field Update Set n:
As the name suggests that this user property is used to set value of another field when a particular field is updated. In this user property n is the incremental number which is 1 more than the number used in the last On Field Update Set user property.
The value of the On Field Update Set user property consists of three quoted parameters separated by a comma and a space which is as following “FieldToCheck”, “FieldToSet”, “[Value]”
You want to set TargetField with SourceField value whenever SourceField is updated. So you will specify it like this.
Property: On Field Update Set 1
Value : “SourceField”, “TargetField”, “[SourceField]”
You can also make use of expression in the Value that you specify.
“SourceField”, “TargetField”, “[SourceField] + [AnotherField]”