From 6d87ef3695e3bf73546bbf4846cb6db68bf565e3 Mon Sep 17 00:00:00 2001 From: Derek Finlinson Date: Thu, 14 Sep 2017 16:35:59 -0600 Subject: [PATCH] Add remaining missing Xrm.Page.data.process methods --- types/xrm/index.d.ts | 116 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 114 insertions(+), 2 deletions(-) diff --git a/types/xrm/index.d.ts b/types/xrm/index.d.ts index 26cba57ab5..a3b49f391d 100644 --- a/types/xrm/index.d.ts +++ b/types/xrm/index.d.ts @@ -893,7 +893,12 @@ declare namespace Xrm { /** * Status for Xrm.Page.Stage.getStatus(). */ - type Status = "active" | "inactive"; + type StageStatus = "active" | "inactive"; + + /** + * Status for Xrm.Page.Process.getStatus(). + */ + type ProcessStatus = "active" | "aborted" | "finished"; /** * Submit Mode for Xrm.Page.Attribute.getSubmitMode() and Xrm.Page.Attribute.setSubmitMode(). @@ -1022,7 +1027,7 @@ declare namespace Xrm { * * @remarks This method will return either "active" or "inactive". */ - getStatus(): Status; + getStatus(): StageStatus; /** * Returns a collection of steps in the stage. @@ -1153,6 +1158,12 @@ declare namespace Xrm { */ type ContextSensitiveHandler = (context: EventContext) => void; + /** + * Type for a process status change handler. + * @param {ProcessStatus} status The process status. + */ + type ProcessStatusChangeHandler = (status: ProcessStatus) => void; + /** * Interface for UI elements with labels. */ @@ -2007,6 +2018,21 @@ declare namespace Xrm { */ setActiveProcess(processId: string, callbackFunction?: ProcessCallbackDelegate): void; + /** + * Returns all process instances for the entity record that the calling user has access to. + * + * @param {function} callbackFunction (Optional) a function to call when the operation is complete. + */ + getProcessInstances(callbackFunction: GetProcessInstancesDelegate): void; + + /** + * Sets a process instance as the active instance + * + * @param {string} processInstanceId The Id of the process instance to make the active instance. + * @param {function} callbackFunction (Optional) a function to call when the operation is complete. + */ + setActiveProcessInstance(processInstanceId: string, callbackFunction: SetProcessInstanceDelegate): void; + /** * Returns a Stage object representing the active stage. * @@ -2069,6 +2095,19 @@ declare namespace Xrm { */ addOnStageChange(handler: ContextSensitiveHandler): void; + /** + * Use this to add a function as an event handler for the OnProcessStatusChange event so that it will be called when the + * business process flow status changes. + * @param {ProcessStatusChangeHandler} handler The function will be added to the bottom of the event + * handler pipeline. The execution context is automatically + * set to be the first parameter passed to the event handler. + * + * Use a reference to a named function rather than an + * anonymous function if you may later want to remove the + * event handler. + */ + addOnProcessStatusChange(handler: ProcessStatusChangeHandler): void; + /** * Use this to add a function as an event handler for the OnStageSelected event so that it will be called * when a business process flow stage is selected. @@ -2083,6 +2122,14 @@ declare namespace Xrm { */ addOnStageSelected(handler: ContextSensitiveHandler): void; + /** + * Use this to remove a function as an event handler for the OnProcessStatusChange event. + * + * @param {ProcessStatusChangeHandler} handler If an anonymous function is set using the addOnProcessStatusChange method it + * cannot be removed using this method. + */ + removeOnProcessStatusChange(handler: ProcessStatusChangeHandler): void; + /** * Use this to remove a function as an event handler for the OnStageChange event. * @@ -2114,8 +2161,62 @@ declare namespace Xrm { * complete. */ movePrevious(callbackFunction?: ProcessCallbackDelegate): void; + + /** + * Use this method to get the unique identifier of the process instance + * + * @return The unique identifier of the process instance + */ + getInstanceId(): string; + + /** + * Use this method to get the name of the process instance + * + * @return The name of the process instance + */ + getInstanceName(): string; + + /** + * Use this method to get the current status of the process instance + * + * @return The current status of the process + */ + getStatus(): ProcessStatus; + + /** + * Use this method to set the current status of the process instance + * + * @param {ProcessStatus} status The new status for the process + * @param {function} callbackFunction (Optional) a function to call when the operation is complete. + */ + setStatus(status: ProcessStatus, callbackFunction: ProcessSetStatusDelegate): void; } + /** + * Called when method to get active processes is complete + * + * @param {string} status The result of the get active processes operation. + * + * @remarks Returns object with the following key-value pairs: + * CreatedOn + * ProcessDefinitionID + * ProcessDefinitionName + * ProcessInstanceID + * ProcessInstanceName + * StatusCodeName + */ + type GetProcessInstancesDelegate = (object: ProcessDictionary) => void; + + /** + * Called when method to set active process is complete + * + * @param {string} status The result of the set active process operation. + * + * @remarks Values returned are: success (The operation succeeded.) + * invalid (The processInstanceId isn’t valid or the process isn’t enabled.) + */ + type SetProcessInstanceDelegate = (status: string) => void; + /** * Called when process change methods have completed. * @@ -2130,6 +2231,17 @@ declare namespace Xrm { */ type ProcessCallbackDelegate = (status: string) => void; + /** + * Called when process set status method has completed. + * + * @param {ProcessStatus} status The new status of the process instance + * + * @remarks Values returned are: active + * aborted + * finished + */ + type ProcessSetStatusDelegate = (status: ProcessStatus) => void; + /** * Represents a key-value pair, where the key is the Process Flow's ID, and the value is the name thereof. */