There are many scenarios which requires a custom action to be performed after saving a record. For example:
- Set its status
- Add a relationship,
- Update a field,
- Update another record
- Call a model dialog etc
Microosft SDK has given this feature using which we can easily add or remove any method after save.
methods are:
- Xrm.Page.data.entity.addOnSave
- Xrm.Page.data.entity.removeOnSave
function
addActionToOnSave() {
Xrm.Page.data.entity.addOnSave(setRecordStatusInactive);
}
function
removeActionFromOnSave() {
Xrm.Page.data.entity.removeOnSave(setRecordStatusInactive);
}
function
setRecordStatusInactive() {
//code to set record status inactive
}
Hope this will help you.