Skip to content

Commit 18834c9

Browse files
author
skovlund
committed
Added preventDefaultOnError to Save Event
Fixed typings for Post Save Event
1 parent f59dc61 commit 18834c9

1 file changed

Lines changed: 28 additions & 2 deletions

File tree

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

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ declare namespace Xrm {
467467
* For example: quickViewControl.getControl("firstname") or quickViewControl.getControl(0)
468468
* Returns an Object or Object collection
469469
*/
470-
getControl(arg?: string) : any // TODO figure out return type. Maybe: Xrm.AnyControl | undefined;
470+
getControl(arg?: string): any // TODO figure out return type. Maybe: Xrm.AnyControl | undefined;
471471
/**
472472
* Returns a string value that categorizes quick view controls.
473473
* For a quick view control, the method returns "quickform".
@@ -684,13 +684,39 @@ declare namespace Xrm {
684684
setSearchQuery(text: string): void;
685685
}
686686

687+
interface SaveEventArgs {
688+
/**
689+
* 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.
690+
*/
691+
preventDefaultOnError(): void;
692+
}
693+
694+
interface PostSaveEventContext extends ExecutionContext<null, PostSaveEventArgs> { }
695+
696+
interface PostSaveEventArgs {
697+
/**
698+
* Use this method to know information about a table being saved/updated. It returns table ID, and table name if success.
699+
*/
700+
getEntityReference(): EntityReference<string>;
701+
702+
/**
703+
* Use this method to know the error details on why a table save failed.
704+
*/
705+
getSaveErrorInfo(): any | null; // TODO: Figure out proper typing
706+
707+
/**
708+
* Use this method to know whether the OnSave operation is successful or failed.
709+
*/
710+
getIsSaveSuccess(): boolean;
711+
}
712+
687713
interface PageEntity<T extends AttributeCollectionBase> {
688714
/**
689715
* Adds a function to be called when save event has completed; either successfully or with a failure.
690716
* @param functionRef The function to add to the PostSave event.
691717
* The execution context is automatically passed as the first parameter to this function.
692718
*/
693-
addOnPostSave(functionRef: (context?: SaveEventContext<this>) => any): void;
719+
addOnPostSave(functionRef: (context?: PostSaveEventContext) => any): void;
694720
}
695721

696722
/**

0 commit comments

Comments
 (0)