Skip to content

Commit 1ae4f3a

Browse files
authored
Merge pull request #268 from delegateas/262-save-events
Save and Post Save Events
2 parents b52617a + dd2c270 commit 1ae4f3a

2 files changed

Lines changed: 3233 additions & 1379 deletions

File tree

src/XrmDefinitelyTyped/Resources/Extensions/xrm_ext_9.1-.d.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,32 @@ declare namespace Xrm {
692692
setSearchQuery(text: string): void;
693693
}
694694

695+
interface SaveEventArgs {
696+
/**
697+
* Cancels the save operation if the event handler has a script error, returns a rejected promise for an async event handler or the operation times out.
698+
*/
699+
preventDefaultOnError(): void;
700+
}
701+
702+
interface PostSaveEventContext extends ExecutionContext<null, PostSaveEventArgs> { }
703+
704+
interface PostSaveEventArgs {
705+
/**
706+
* Use this method to know information about a table being saved/updated. It returns table ID, and table name if success.
707+
*/
708+
getEntityReference(): EntityReference<string>;
709+
710+
/**
711+
* Use this method to know the error details on why a table save failed.
712+
*/
713+
getSaveErrorInfo(): any | null; // TODO: Figure out proper typing
714+
715+
/**
716+
* Use this method to know whether the OnSave operation is successful or failed.
717+
*/
718+
getIsSaveSuccess(): boolean;
719+
}
720+
695721
// eslint-disable-next-line @typescript-eslint/no-unused-vars
696722
interface PageEntity<T extends AttributeCollectionBase> {
697723
/**
@@ -700,7 +726,7 @@ declare namespace Xrm {
700726
* The execution context is automatically passed as the first parameter to this function.
701727
*/
702728
// eslint-disable-next-line @typescript-eslint/no-explicit-any
703-
addOnPostSave(functionRef: (context?: SaveEventContext<this>) => any): void;
729+
addOnPostSave(functionRef: (context?: PostSaveEventContext) => any): void;
704730
}
705731

706732
/**

0 commit comments

Comments
 (0)