Skip to main content

Function: MnOnSave

MnOnSave(): (target: any, key: any, descriptor: PropertyDescriptor) => void

Decorator that marks a method as an event handler for save event.

This event is fired when:

  • The user clicks the save button.
  • save() method is called.
  • Auto save is triggered.
  • refresh(true) method is called.

Remarks

Available on pages: Record only.

Registration: Automatic registration at runtime.

For more information, see Microsoft Client API Reference

Example

Prevent auto save

@MnComponent({
scope: {
pageType: "record",
table: "account"
}
})
export class PreventAutoSaveComponent {
@MnOnSave()
onSave(eventArg: FormEventArg) {
const args = eventArg.eventCtx.getEventArgs();
if (args.getSaveMode() === XrmEnum.SaveMode.AutoSave) {
args.preventDefault();
}
}
}

Returns

fn

▸ (target, key, descriptor): void

Parameters
NameType
targetany
keyany
descriptorPropertyDescriptor
Returns

void

Defined in

packages/core/src/core/metadata/events.ts:689