Skip to content

Commit

Permalink
Added preventDefaultOnError to Save Event
Browse files Browse the repository at this point in the history
Fixed typings for Post Save Event
  • Loading branch information
skovlund committed Apr 20, 2022
1 parent f59dc61 commit 18834c9
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions src/XrmDefinitelyTyped/Resources/Extensions/xrm_ext_9.1-.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ declare namespace Xrm {
* For example: quickViewControl.getControl("firstname") or quickViewControl.getControl(0)
* Returns an Object or Object collection
*/
getControl(arg?: string) : any // TODO figure out return type. Maybe: Xrm.AnyControl | undefined;
getControl(arg?: string): any // TODO figure out return type. Maybe: Xrm.AnyControl | undefined;
/**
* Returns a string value that categorizes quick view controls.
* For a quick view control, the method returns "quickform".
Expand Down Expand Up @@ -684,13 +684,39 @@ 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;
}

interface PageEntity<T extends AttributeCollectionBase> {
/**
* Adds a function to be called when save event has completed; either successfully or with a failure.
* @param functionRef The function to add to the PostSave event.
* The execution context is automatically passed as the first parameter to this function.
*/
addOnPostSave(functionRef: (context?: SaveEventContext<this>) => any): void;
addOnPostSave(functionRef: (context?: PostSaveEventContext) => any): void;
}

/**
Expand Down

0 comments on commit 18834c9

Please sign in to comment.