Skip to content

Commit

Permalink
Merge pull request #268 from delegateas/262-save-events
Browse files Browse the repository at this point in the history
Save and Post Save Events
  • Loading branch information
misoeli authored May 20, 2022
2 parents b52617a + dd2c270 commit 1ae4f3a
Show file tree
Hide file tree
Showing 2 changed files with 3,233 additions and 1,379 deletions.
28 changes: 27 additions & 1 deletion src/XrmDefinitelyTyped/Resources/Extensions/xrm_ext_9.1-.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,32 @@ declare namespace Xrm {
setSearchQuery(text: string): void;
}

interface SaveEventArgs {
/**
* 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.
*/
preventDefaultOnError(): void;
}

interface PostSaveEventContext extends ExecutionContext<null, PostSaveEventArgs> { }

interface PostSaveEventArgs {
/**
* Use this method to know information about a table being saved/updated. It returns table ID, and table name if success.
*/
getEntityReference(): EntityReference<string>;

/**
* Use this method to know the error details on why a table save failed.
*/
getSaveErrorInfo(): any | null; // TODO: Figure out proper typing

/**
* Use this method to know whether the OnSave operation is successful or failed.
*/
getIsSaveSuccess(): boolean;
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface PageEntity<T extends AttributeCollectionBase> {
/**
Expand All @@ -700,7 +726,7 @@ declare namespace Xrm {
* The execution context is automatically passed as the first parameter to this function.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
addOnPostSave(functionRef: (context?: SaveEventContext<this>) => any): void;
addOnPostSave(functionRef: (context?: PostSaveEventContext) => any): void;
}

/**
Expand Down
Loading

0 comments on commit 1ae4f3a

Please sign in to comment.