From 8d44b7df0e8a4f28faad0aa5c25bc7d484949c54 Mon Sep 17 00:00:00 2001 From: "Derek C. Finlinson" Date: Tue, 15 Nov 2016 13:37:36 -0700 Subject: [PATCH 1/4] Update SuccessCallbackDelegate definition --- xrm/xrm.d.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xrm/xrm.d.ts b/xrm/xrm.d.ts index 986ce7e78a..1d8aa521ff 100644 --- a/xrm/xrm.d.ts +++ b/xrm/xrm.d.ts @@ -483,8 +483,10 @@ declare namespace Xrm { /** * Called when the operation is successful. + * Currently, only the Xrm.Utility.openQuickCreate successCallback + * is passed a parameter so an optional parameter for it is included */ - export type SuccessCallbackDelegate = ( object: any ) => void; + export type SuccessCallbackDelegate = ( savedEntityReference?: Page.LookupValue ) => void; /** * Called when the operation fails. From a90abe4d4f067c2cbb6274ee97762f35fb2d276c Mon Sep 17 00:00:00 2001 From: "Derek C. Finlinson" Date: Tue, 15 Nov 2016 13:49:12 -0700 Subject: [PATCH 2/4] Fix ErrorCallbackDelegate signature --- xrm/xrm-tests.ts | 2 +- xrm/xrm.d.ts | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/xrm/xrm-tests.ts b/xrm/xrm-tests.ts index ac0f115154..64fb9e8c22 100644 --- a/xrm/xrm-tests.ts +++ b/xrm/xrm-tests.ts @@ -72,7 +72,7 @@ if (Xrm.Page.data.process != null) /// Demonstrate v7.1 Quick Create form -Xrm.Utility.openQuickCreate("account").then(( newRecord: Xrm.Page.LookupValue ) => { alert( `Newly created record Id: ${newRecord.id}` ); }, (code, message) => {console.log(message)}); +Xrm.Utility.openQuickCreate("account").then(( newRecord: Xrm.Page.LookupValue ) => { alert( `Newly created record Id: ${newRecord.id}` ); }, (error) => {console.log(`Code: ${error.errorCode}, Message: ${error.message}`)}); /// Make all controls visible. diff --git a/xrm/xrm.d.ts b/xrm/xrm.d.ts index ff42d8f005..b78174523a 100644 --- a/xrm/xrm.d.ts +++ b/xrm/xrm.d.ts @@ -481,6 +481,15 @@ declare namespace Xrm */ export module Async { + /** + * Object passed to ErrorCallbackDelegate + */ + export interface ErrorCallbackObject + { + errorCode: number; + message: string; + } + /** * Called when the operation is successful. * Currently, only the Xrm.Utility.openQuickCreate successCallback @@ -491,10 +500,9 @@ declare namespace Xrm /** * Called when the operation fails. * - * @param {number} errorCode The error code. - * @param {string} message The message. + * @param {ErrorCallbackObject} error The error object */ - export type ErrorCallbackDelegate = ( errorCode: number, message: string ) => void; + export type ErrorCallbackDelegate = ( error: ErrorCallbackObject ) => void; /** * Interface for Xrm.Page.data promises. From 2681fb04c1bfe98a1b630d1dda2fef99897f9786 Mon Sep 17 00:00:00 2001 From: Derek Finlinson Date: Tue, 15 Nov 2016 20:12:37 -0700 Subject: [PATCH 3/4] Correct SuccessCallbackDelegate parameter --- xrm/xrm.d.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/xrm/xrm.d.ts b/xrm/xrm.d.ts index b78174523a..393594da19 100644 --- a/xrm/xrm.d.ts +++ b/xrm/xrm.d.ts @@ -489,13 +489,18 @@ declare namespace Xrm errorCode: number; message: string; } + + export interface SuccessCallbackObject + { + savedEntityReference: Page.LookupValue; + } /** * Called when the operation is successful. * Currently, only the Xrm.Utility.openQuickCreate successCallback * is passed a parameter so an optional parameter for it is included */ - export type SuccessCallbackDelegate = ( savedEntityReference?: Page.LookupValue ) => void; + export type SuccessCallbackDelegate = (object?: SuccessCallbackObject ) => void; /** * Called when the operation fails. From 67ba8bbf82b139fcbf4f78971f7e75c39bf64e1e Mon Sep 17 00:00:00 2001 From: "Derek C. Finlinson" Date: Tue, 15 Nov 2016 20:16:36 -0700 Subject: [PATCH 4/4] Update openQuickCreate success test --- xrm/xrm-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xrm/xrm-tests.ts b/xrm/xrm-tests.ts index 64fb9e8c22..68ed23abb1 100644 --- a/xrm/xrm-tests.ts +++ b/xrm/xrm-tests.ts @@ -72,7 +72,7 @@ if (Xrm.Page.data.process != null) /// Demonstrate v7.1 Quick Create form -Xrm.Utility.openQuickCreate("account").then(( newRecord: Xrm.Page.LookupValue ) => { alert( `Newly created record Id: ${newRecord.id}` ); }, (error) => {console.log(`Code: ${error.errorCode}, Message: ${error.message}`)}); +Xrm.Utility.openQuickCreate("account").then(( object ) => { alert( `Newly created record Id: ${object.savedEntityReference.id}` ); }, (error) => {console.log(`Code: ${error.errorCode}, Message: ${error.message}`)}); /// Make all controls visible.