IObjectPropertyAutoAction
By implementing the IObjectPropertyAutoAction interface in a application script, you can define custom actions that are automatically performed when the user manually modifies the value of an object property.
Interface methods are also called in both variants of the Alvao.API.AM.ObjectProperty.Update method. These methods cannot be called in running transaction (if calling them is necessary, set the callCustomAction parameter to false). The AM Console command - Properties tab - Generate Value does not call the OnObjectPropertyModifying method. It only calls the OnObjectPropertyModified method.
If you want to use only some of the methods of the implemented interface in the automatic action, leave an exception in the body of the other methods from the interface:
throw new NotImplementedException();
.
Interface methods
Method | Description |
---|---|
OnObjectPropertyModifying | The value of the property will be changed. |
OnObjectPropertyModified | The value of the property has been changed. |
OnObjectPropertyModifying
This method is called before saving the modified property value to the database, e.g. within the Modify (property) statement.
- Syntax: ObjectPropertyModifyResult OnObjectPropertyModifying(ObjectPropertyEventArgs e)
- Parameters:
- e - Property event method parameters
-
- ObjectId - ID of the object (tblNode.intNodeId) that is being modified.
- PropertyKindId - ID of the property kind (tblKind.intKindId) of the object that is being modified.
- PersonId - the ID of the user (tPerson.iPersonId) who invoked the action.
- NewValue - new value of the property.
- ObjectId - ID of the object (tblNode.intNodeId) that is being modified.
- Return values:
- ObjectPropertyModifyResult
-
- Success (bool) - if the method returns true, the new value is written to the database. If the method returns false, the operation is not performed and the upcoming property value change is canceled.
- Message (string) - the message that is displayed to the user if the return value is false.
- Success (bool) - if the method returns true, the new value is written to the database. If the method returns false, the operation is not performed and the upcoming property value change is canceled.
For an example, see the CheckPhoneNumberFormat application template.
OnObjectPropertyModified
This method is called after writing a new property value to the database, e.g. by the *Modify (property)*statement.
- Syntax: void OnPropertyModified(ObjectPropertyEventArgs e)
- Parameters:
- e - Property event method parameters
-
- ObjectId - ID of the object (tblNode.intNodeId) that is being modified.
- PropertyKindId - ID of the property kind (tblKind.intKindId) of the object that is being modified.
- PersonId - the ID of the user (tPerson.iPersonId) who invoked the action.
- NewValue - new value of the property.
- ObjectId - ID of the object (tblNode.intNodeId) that is being modified.
- Return value: none.
For an example use case, see the CopyNewPropertyValueToAnotherProperty application template.