diff --git a/xrm/index.d.ts b/xrm/index.d.ts
index 36bd556c13..bd70a6098d 100644
--- a/xrm/index.d.ts
+++ b/xrm/index.d.ts
@@ -1,7 +1,8 @@
-// Type definitions for Microsoft Dynamics xRM API v8.0
+// Type definitions for Microsoft Dynamics xRM API v8.2
// Project: http://www.microsoft.com/en-us/download/details.aspx?id=44567
-// Definitions by: David Berry , Matt Ngan , Markus Mauch , Daryl LaBar
+// Definitions by: David Berry , Matt Ngan , Markus Mauch , Daryl LaBar , Tully H
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+// TypeScript Version: 2.1
declare var Xrm: Xrm.XrmStatic;
declare function GetGlobalContext(): Xrm.Context;
@@ -93,7 +94,7 @@ declare namespace Xrm
* Gets a control matching controlName.
*
* @tparam T A Control type
- * @param {string} controlName Name of the control.
+ * @param {string} controlName Name of the control.
*
* @return The control.
*/
@@ -102,12 +103,22 @@ declare namespace Xrm
/**
* Gets a control matching controlName.
*
- * @param {string} controlName Name of the control.
+ * @param {string} controlName Name of the control.
*
* @return The control.
*/
getControl( controlName: string ): Page.Control;
+ /**
+ * Gets a control by index.
+ *
+ * @tparam T A Control type
+ * @param {number} index The control index.
+ *
+ * @return The control.
+ */
+ getControl( index: number ): T;
+
/**
* Gets a control by index.
*
@@ -125,7 +136,7 @@ declare namespace Xrm
* @return An array of control.
*/
getControl( delegateFunction: Collection.MatchingDelegate ): Page.Control[];
- }
+ };
/**
* Provides a container for useful functions not directly related to the current page.
@@ -166,11 +177,10 @@ declare namespace Xrm
* @param {OpenParameters} parameters (Optional) A dictionary object that passes extra query string
* parameters to the form. Invalid query string parameters will cause an
* error.
+ * @return {Async.XrmPromise} Returns an asynchronous promise.
*/
- openQuickCreate(
- entityLogicalName: string,
- createFromEntity?: Page.LookupValue,
- parameters?: Utility.OpenParameters ): Async.XrmPromise;
+ openQuickCreate( entityLogicalName: string, createFromEntity?: Page.LookupValue, parameters?: Utility.OpenParameters ):
+ Async.XrmPromise;
/**
* Opens an entity form.
@@ -204,17 +214,41 @@ declare namespace Xrm
* formid
*/
openWebResource( webResourceName: string, webResourceData?: string, width?: number, height?: number ): Window;
- }
+ };
+
+ /**
+ * Provides methods to create and manage records in the mobile clients (for phones tablets).
+ */
+ Mobile: Mobile;
+
+ /**
+ * Provides methods to display a web page in the side pane of web client.
+ *
+ * @see {@link https://msdn.microsoft.com/en-us/library/mt790281.aspx} for details.
+ */
+ Panel: {
+ /**
+ * Displays the web page represented by a URL in the static area in the side pane, which appears on all pages in the web client.
+ *
+ * @param {string} url URL of the page to be loaded in the side pane static area.
+ * @param {string} url Title of the side pane static area.
+ *
+ * @remarks This method is only supported for the web client.
+ */
+ LoadPanel(url: string, title: string): void;
+ };
}
/**
* Client Types for Xrm.Page.context.getClient().
*/
export type Client = "Web" | "Outlook" | "Mobile";
+
/**
* Client States for Xrm.Page.context.getClientState().
*/
export type ClientState = "Online" | "Offline";
+
/**
* Themes for Xrm.Page.context.getCurrentTheme().
*/
@@ -243,7 +277,7 @@ declare namespace Xrm
/**
* Interface for the xRM application context.
*/
- interface Context
+ export interface Context
{
/**
* The client's context instance.
@@ -254,6 +288,7 @@ declare namespace Xrm
* Gets client's base URL for Dynamics CRM
*
* @return The client's base URL
+ *
* @remarks For Dynamics CRM On-Premises: http(s)://server/org
* For Dynamics CRM Online: https://org.crm.dynamics.com
* For Dynamics CRM for Outlook (Offline): http://localhost:2525
@@ -354,6 +389,20 @@ declare namespace Xrm
prependOrgName( sPath: string ): string;
}
+ /**
+ * Defines save options to control how appointment, recurring appointment, or service activity records are processed.
+ *
+ * @see {@link https://msdn.microsoft.com/en-us/library/dn481607.aspx#Anchor_2} for details.
+ */
+ export interface SaveOptions
+ {
+ /**
+ * Indicates whether to use the Book or Reschedule messages rather than the Create or Update messages.
+ * Applicable to appointment, recurring appointment, or service activity records.
+ */
+ UseSchedulingEngine?: boolean;
+ }
+
/**
* Interface for the Xrm.Page.data object.
*/
@@ -364,16 +413,25 @@ declare namespace Xrm
*
* @param {boolean} save true to save the record, after the refresh.
*
- * @return An Async.XrmPromise.
+ * @return {Async.XrmPromise} Returns an asynchronous promise.
*/
- refresh( save: boolean ): Async.XrmPromise;
+ refresh( save: boolean ): Async.XrmPromise;
/**
* Asynchronously saves the record.
*
- * @return An Async.XrmPromise.
+ * @return {Async.XrmPromise} Returns an asynchronous promise.
*/
- save(): Async.XrmPromise;
+ save(): Async.XrmPromise;
+
+ /**
+ * Asynchronously saves the record with the option to set callback functions to be executed after the save operation is completed.
+ *
+ * @param {saveOptions} saveOptions Options to control how appointment, recurring appointment, or service activity records are processed.
+ *
+ * @return {Async.XrmPromise} Returns an asynchronous promise.
+ */
+ save( saveOptions: SaveOptions ): Async.XrmPromise;
/**
* The record context of the form.
@@ -393,12 +451,27 @@ declare namespace Xrm
*/
export interface Ui
{
+ /**
+ * Displays a form level notification. Any number of notifications can be displayed and will remain until removed using clearFormNotification.
+ * The height of the notification area is limited so each new message will be added to the top.
+ *
+ * @param {string} message The text of the notification message.
+ * @param {Page.ui.FormNotificationLevel} level The level of the notification which defines how the message will be displayed, such as the icon.
+ * @param {string} uniqueId Unique identifier for the notification which is used with clearFormNotification to remove the notification.
+ *
+ * @return true if it succeeds, otherwise false.
+ *
+ * @remarks Values for level are: ERROR Notification will use the system error icon. * WARNING Notification will use the system warning icon.
+ * INFO Notification will use the system info icon.
+ */
+ setFormNotification( message: string, level: Page.ui.FormNotificationLevel, uniqueId: string ): boolean;
+
/**
* Clears the form notification described by uniqueId.
*
* @param {string} uniqueId Unique identifier.
*
- * @return true if it succeeds, otherwise false.
+ * @return True if it succeeds, otherwise false.
*/
clearFormNotification( uniqueId: string ): boolean;
@@ -441,14 +514,15 @@ declare namespace Xrm
getViewPortWidth(): number;
/**
- * Re-evaluates the ribbon's configured EnableRules
+ * Re-evaluates the ribbon's configured EnableRules.
*
* @remarks This method does not work with Microsoft Dynamics CRM for tablets.
*/
refreshRibbon(): void;
- setFormNotification(message: string, level: Page.ui.FormNotificationLevel | string, uniqueId: string ): boolean;
-
+ /**
+ * The business process flow API, used to interact with the business process flow control in a form.
+ */
process: Page.ui.ProcessManager;
/**
@@ -474,6 +548,127 @@ declare namespace Xrm
* A reference to the collection of tabs on the form.
*/
tabs: Collection.ItemCollection;
+
+ /**
+ * A collection of all the quick view controls on a form using the new form rendering engine (also called "turbo forms").
+ */
+ quickForms: Collection.ItemCollection;
+ }
+
+ /**
+ * Interface for methods to create and manage records in the mobile clients (for phones tablets).
+ */
+ export interface Mobile
+ {
+ /**
+ * Provides methods to create and manage records in the mobile clients while working in the offline mode.
+ *
+ * @see {@link https://msdn.microsoft.com/en-us/library/mt787123.aspx} for details.
+ */
+ offline: MobileOffline;
+ }
+
+ /**
+ * Interface for the Mobile.offline methods to create and manage records in the mobile clients while working in the offline mode.
+ *
+ * @see {@link https://msdn.microsoft.com/en-us/library/mt787123.aspx} for details.
+ */
+ export interface MobileOffline
+ {
+ /**
+ * Returns whether an entity is offline enabled.
+ *
+ * @param {string} entityType The logical name of the entity.
+ *
+ * @return {boolean} True if the entity is offline enabled; otherwise False.
+ */
+ isOfflineEnabled( entityType: string ): boolean;
+
+ /**
+ * Creates an entity record in mobile clients while working in the offline mode.
+ *
+ * @param {string} entityType The logical name of the entity.
+ * @param {Object} data A dictionary object containing key : value pairs for the record to create.
+ *
+ * @return {Async.XrmPromise} Returns an asynchronous promise.
+ *
+ * @remarks You cannot create intersect and activity party entities.
+ * Only the following attribute types are supported in offline mode:
+ * BigInt, Boolean, Customer, DateTime, Decimal, Double, EntityName
+ * Integer, Lookup, Memo, Money, Owner, Picklist, String, State
+ * Status, UniqueIdentifier
+ */
+ createRecord( entityType: string, data: { [attributeName: string]: any } ): Async.XrmPromise;
+
+ /**
+ * Retrieves an entity record in mobile clients while working in the offline mode.
+ *
+ * @param {string} entityType The logical name of the entity.
+ * @param {string} id GUID of the record to retrieve.
+ * @param {string} options (Optional) OData system query options to retrieve your data. Supports $select and $expand
+ * Example: ?$select=name&$expand=primarycontactid($select=contactid,fullname)
+ *
+ * @return {Async.XrmPromise} Returns an asynchronous promise.
+ *
+ * @remarks Only $select option can be specified within $expand.
+ * Only the following attribute types are supported in offline mode:
+ * BigInt, Boolean, Customer, DateTime, Decimal, Double, EntityName
+ * Integer, Lookup, Memo, Money, Owner, Picklist, String, State
+ * Status, UniqueIdentifier
+ */
+ retrieveRecord( entityType: string, id: string, options: string ): Async.XrmPromise;
+
+ /**
+ * Retrieves a collection of entity records in mobile clients while working in the offline mode.
+ *
+ * @param {string} entityType The logical name of the entity.
+ * @param {string} options (Optional) The logical name of the enti
+ * @param {string} maxPageSize (Optional) A positive number to indicates the number of entity records to be returned per page.
+ * If you do not specify this parameter, the default value is passed as 5000.
+ * If the number of records being retrieved is more than maxPageSize, an @odata.nextLink property
+ * will be returned, and you can use the value of the @odata.nextLink property with a new GET
+ * request to return next set of records.
+ *
+ * @return {Async.XrmPromise} Returns an asynchronous promise.
+ *
+ * @remarks A maximum of 5000 related records can be retrieved when using $expand.
+ * Only $select option can be specified within $expand.
+ * $skip query option is not supported.
+ * Only the following attribute types are supported in offline mode:
+ * BigInt, Boolean, Customer, DateTime, Decimal, Double, EntityName
+ * Integer, Lookup, Memo, Money, Owner, Picklist, String, State
+ * Status, UniqueIdentifier
+ */
+ retrieveMultipleRecords( entityType: string, options: string, maxPageSize: number ): Async.XrmPromise;
+
+ /**
+ * Updates an entity record in mobile clients while working in the offline mode.
+ *
+ * @param {string} entityType The logical name of the entity.
+ * @param {string} id GUID of the record to update.
+ * @param {Object} data A dictionary object containing key : value pairs for the record to update.
+ *
+ * @return {Async.XrmPromise} Returns an asynchronous promise.
+ *
+ * @remarks You cannot update intersect and activity party entities.
+ * Only the following attribute types are supported in offline mode:
+ * BigInt, Boolean, Customer, DateTime, Decimal, Double, EntityName
+ * Integer, Lookup, Memo, Money, Owner, Picklist, String, State
+ * Status, UniqueIdentifier
+ */
+ updateRecord( entityType: string, id: string, data: { [attributeName: string]: any } ): Async.XrmPromise;
+
+ /**
+ * Deletes an entity record in mobile clients while working in the offline mode.
+ *
+ * @param {string} entityType The logical name of the entity.
+ * @param {string} id GUID of the record to delete.
+ *
+ * @return {Async.XrmPromise} Returns an asynchronous promise.
+ *
+ * @remarks You cannot delete intersect and activity party entities.
+ */
+ deleteRecord( entityType: string, id: string ): Async.XrmPromise;
}
/**
@@ -481,38 +676,115 @@ declare namespace Xrm
*/
export module Async
{
- /**
- * Object passed to ErrorCallbackDelegate
- */
- export interface ErrorCallbackObject
- {
- 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 = (object?: SuccessCallbackObject ) => void;
-
+ export type SuccessCallbackDelegate = () => void;
+
/**
* Called when the operation fails.
*
- * @param {ErrorCallbackObject} error The error object
+ * @param {ErrorCallbackObject} error The error object.
*/
export type ErrorCallbackDelegate = ( error: ErrorCallbackObject ) => void;
/**
- * Interface for Xrm.Page.data promises.
+ * Called when the Xrm.Utility.openQuickCreate operation is successful and a new record has been created.
+ *
+ * @param {OpenQuickCreateSuccessCallbackObject} record An object which contains a lookup value which identifies the record which has been created.
+ *
+ * @see {Xrm.Utility.openQuickCreate}
*/
- export interface XrmPromise
+ export type QuickCreateSuccessCallbackDelegate = ( record: OpenQuickCreateSuccessCallbackObject ) => void;
+
+ /**
+ * Called when the offline operation is successful.
+ *
+ * @param {OfflineOperationSuccessCallbackObject} record The record returned from the operation.
+ *
+ * @see {Xrm.Mobile.offline}
+ */
+ export type OfflineOperationSuccessCallbackDelegate = ( record: OfflineOperationSuccessCallbackObject ) => void;
+
+ /**
+ * Called when the offline retrieve multiple operation is successful.
+ *
+ * @param {OfflineRetrieveMultipleSuccessCallbackDelegate} resultSet The dictionary of records retrieved from the operation.
+ *
+ * @see {Xrm.Mobile.offline.retrieveMultipleRecords}
+ */
+ export type OfflineRetrieveMultipleSuccessCallbackDelegate = (resultSet: { [key: string]: any }[]) => void;
+
+ /**
+ * Called when the operation fails.
+ *
+ * @param {OfflineErrorCallbackObject} error The error object.
+ *
+ * @see {Xrm.Mobile.offline}
+ */
+ export type OfflineErrorCallbackDelegate = (error: OfflineErrorCallbackObject) => void;
+
+ /**
+ * Object passed to ErrorCallbackDelegate.
+ */
+ export interface ErrorCallbackObject
+ {
+ /**
+ * The error code.
+ */
+ errorCode: number;
+
+ /**
+ * An error message describing the issue.
+ */
+ message: string;
+ }
+
+ /**
+ * Object passed to QuickCreateSuccessCallbackDelegate.
+ */
+ export interface OpenQuickCreateSuccessCallbackObject
+ {
+ /**
+ * A lookup value which identifies the record which has been created.
+ */
+ savedEntityReference: Page.LookupValue;
+ }
+
+ /**
+ * Object passed to OfflineOperationSuccessCallbackDelegate;
+ */
+ export interface OfflineOperationSuccessCallbackObject
+ {
+ /**
+ * GUID of the record;
+ */
+ id: string;
+
+ /**
+ * Logical name of the entity.
+ */
+ logicalName: string;
+ }
+
+ /**
+ * Object passed to OfflineErrorCallbackDelegate.
+ */
+ export interface OfflineErrorCallbackObject extends ErrorCallbackObject
+ {
+ /**
+ * An internal error message that might contain additional details about the issue.
+ */
+ debugMessage: string;
+ }
+
+ /**
+ * Interface for asynchronous promises used in Xrm.Page.data and Xrm.Utility.openQuickCreate.
+ *
+ * @tparam TSuccessCallback Generic success callback parameter.
+ * @tparam TErrorCallback Generic error callback parameter.
+ */
+ export interface XrmPromise
{
/**
* A basic 'then' promise.
@@ -520,7 +792,7 @@ declare namespace Xrm
* @param {SuccessCallbackDelegate} successCallback The success callback.
* @param {ErrorCallbackDelegate} errorCallback The error callback.
*/
- then( successCallback: SuccessCallbackDelegate, errorCallback: ErrorCallbackDelegate ): void;
+ then( successCallback: TSuccessCallback, errorCallback: TErrorCallback ): void;
}
}
@@ -564,10 +836,10 @@ declare namespace Xrm
}
/**
- * Interface for an item collection.
- *
- * @tparam T Generic type parameter.
- */
+ * Interface for an item collection.
+ *
+ * @tparam T Generic type parameter.
+ */
export interface ItemCollection
{
/**
@@ -633,31 +905,74 @@ declare namespace Xrm
* Requirement Level for Xrm.Page.Attribute.getRequiredLevel() and Xrm.Page.Attribute.setRequiredLevel().
*/
export type RequirementLevel = "none" | "recommended" | "required";
+
/**
* Save Modes for Xrm.Page.Entity.save().
*/
export type SaveMode = "saveandclose" | "saveandnew";
+
/**
* Status for Xrm.Page.Stage.getStatus().
*/
export type Status = "active" | "inactive";
+
/**
* Submit Mode for Xrm.Page.Attribute.getSubmitMode() and Xrm.Page.Attribute.setSubmitMode().
*/
export type SubmitMode = "always" | "dirty" | "never";
+ /**
+ * Control type for Xrm.Page.ui.QuickForm.getControlType().
+ */
+ export type ControlQuickFormType = "quickform";
+
+ /**
+ * Control types for Xrm.Page.Control.getControlType().
+ */
+ export type ControlType = "standard" | "iframe" | "lookup" | "optionset" | "subgrid" | "webresource" | "notes" | "timercontrol" | "kbsearch" | ControlQuickFormType;
+
+ /**
+ * Date attribute formats for Xrm.Page.Attribute.getFormat(), used by DateAttribute.
+ */
+ export type DateAttributeFormat = "date" | "datetime";
+
+ /**
+ * Integer attribute formats for Xrm.Page.Attribute.getFormat(), used by NumberAttribute.
+ */
+ export type IntegerAttributeFormat = "duration" | "none";
+
+ /**
+ * OptionSet attribute formats for Xrm.Page.Attribute.getFormat(), used by OptionSetAttribute.
+ */
+ export type OptionSetAttributeFormat = "language" | "timezone";
+
+ /**
+ * String attribute formats for Xrm.Page.Attribute.getFormat(), used by StringAttribute.
+ */
+ export type StringAttributeFormat = "email" | "phone" | "text" | "textarea" | "tickersymbol" | "url";
+
+ /**
+ * Attribute types for Xrm.ui.ProcessMonitor Xrm.Page.Attribute.setDisplayState().
+ */
+ export type AttributeType = "boolean" | "datetime" | "decimal" | "double" | "integer" | "lookup" | "memo" | "money" | "optionset" | "string";
+
+ /**
+ * Attribute formats for Xrm.Page.Attribute.getFormat().
+ */
+ export type AttributeFormat = DateAttributeFormat | IntegerAttributeFormat | OptionSetAttributeFormat | StringAttributeFormat;
+
/**
* Interface for a CRM Business Process Flow instance.
*/
export interface Process
{
/**
- * Returns the unique identifier of the process.
- *
- * @return The identifier for this process, in GUID format.
- *
- * @remarks Example: "{825CB223-A651-DF11-AA8B-00155DBA3804}".
- */
+ * Returns the unique identifier of the process.
+ *
+ * @return The identifier for this process, in GUID format.
+ *
+ * @remarks Example: "{825CB223-A651-DF11-AA8B-00155DBA3804}".
+ */
getId(): string;
/**
@@ -836,9 +1151,9 @@ declare namespace Xrm
}
/**
- * Base interface for UI elements.
+ * Interface for UI elements with labels.
*/
- export interface UiElement
+ export interface UiLabelElement
{
/**
* Gets the label.
@@ -846,21 +1161,33 @@ declare namespace Xrm
* @return The label.
*/
getLabel(): string;
-
- /**
- * Gets the visibility state.
- *
- * @return true if the tab is visible, otherwise false.
- */
- getVisible(): boolean;
-
+
/**
* Sets the label.
*
* @param {string} label The label.
*/
setLabel( label: string ): void;
+ }
+ /**
+ * Interface for UI elements which can have the visibility value read.
+ */
+ export interface UiCanGetVisibleElement
+ {
+ /**
+ * Gets the visibility state.
+ *
+ * @return true if the tab is visible, otherwise false.
+ */
+ getVisible(): boolean;
+ }
+
+ /**
+ * Base interface for standard UI elements.
+ */
+ export interface UiStandardElement extends UiCanGetVisibleElement, UiLabelElement
+ {
/**
* Sets the visibility state.
*
@@ -879,15 +1206,44 @@ declare namespace Xrm
*/
setFocus(): void;
}
+
+ /**
+ * Interface for controls which methods provide immediate feedback or take actions as user types in a control.
+ * Contains methods which can be used to perform data validations in a control even before the user commits (saves) the value in a form.
+ */
+ export interface UiKeyPressable
+ {
+ /**
+ * Use this to add a function as an event handler for the keypress event so that the function is called when you type a character in the specific text or number field.
+ * For a sample JavaScript code that uses the addOnKeyPress method to configure the auto-completion experience, see Sample: Auto-complete in CRM controls.
+ *
+ * @param {ContextSensitiveHandler} handler The function reference.
+ */
+ addOnKeyPress( handler: ContextSensitiveHandler ): void;
+
+ /**
+ * Use this to manually fire an event handler that you created for a specific text or number field to be executed on the keypress event.
+ */
+ fireOnKeyPress(): void;
+
+ /**
+ * Use this to remove an event handler for a text or number field that you added using addOnKeyPress.
+ *
+ * Remarks: If an anonymous function is set using addOnKeyPress, it can’t be removed using this method.
+ * @param {ContextSensitiveHandler} handler The function reference.
+ */
+ removeOnKeyPress( handler: ContextSensitiveHandler ): void;
+ }
/**
* Interface for Result value of AutoCompleteResultSet
*/
- export interface AutoCompleteResult {
+ export interface AutoCompleteResult
+ {
/**
* The Identifier
*/
- id: string|number;
+ id: string | number;
/**
* Url of the icon to display
@@ -903,7 +1259,8 @@ declare namespace Xrm
/**
* Interface for command of AutoCompleteResultSet. This is displayed at the bottom of the auto complete view
*/
- export interface AutoCompleteCommand {
+ export interface AutoCompleteCommand
+ {
/**
* The Identifier
*/
@@ -928,7 +1285,8 @@ declare namespace Xrm
/**
* Interface for showAutoComplete argument
*/
- export interface AutoCompleteResultSet {
+ export interface AutoCompleteResultSet
+ {
/**
* Results to show
*/
@@ -983,17 +1341,17 @@ declare namespace Xrm
export interface Privilege
{
/**
- * true if the user can read.
+ * True if the user can read.
*/
canRead: boolean;
/**
- * true if the user can update.
+ * True if the user can update.
*/
canUpdate: boolean;
/**
- * true if the user can create.
+ * True if the user can create.
*/
canCreate: boolean;
}
@@ -1032,7 +1390,7 @@ declare namespace Xrm
* string
*/
getAttributeType(): string;
-
+
/**
* Gets the attribute format.
*
@@ -1053,7 +1411,7 @@ declare namespace Xrm
* timezone (optionset)
* url (string)
*/
- getFormat(): string;
+ getFormat(): AttributeFormat;
/**
* Gets a boolean value indicating whether this Attribute has unsaved changes.
@@ -1111,7 +1469,7 @@ declare namespace Xrm
*
* @param {string} requirementLevel The requirement level, as either "none", "required", or "recommended"
*/
- setRequiredLevel(requirementLevel: RequirementLevel | string): void;
+ setRequiredLevel( requirementLevel: RequirementLevel ): void;
/**
* Sets the submit mode.
@@ -1120,12 +1478,26 @@ declare namespace Xrm
*
* @remarks The default value is "dirty"
*/
- setSubmitMode(submitMode: SubmitMode | string): void;
+ setSubmitMode( submitMode: SubmitMode ): void;
/**
* A collection of all the controls on the form that interface with this attribute.
*/
controls: Collection.ItemCollection;
+
+ /**
+ * Gets the value.
+ *
+ * @return The value.
+ */
+ getValue(): any;
+
+ /**
+ * Sets the value.
+ *
+ * @param {any} value The value.
+ */
+ setValue( value: any ): void;
}
/**
@@ -1135,6 +1507,16 @@ declare namespace Xrm
*/
export interface NumberAttribute extends Attribute
{
+ /**
+ * Gets the attribute format.
+ *
+ * @return The format of the attribute.
+ *
+ * @remarks Values returned are: duration
+ * none
+ */
+ getFormat(): IntegerAttributeFormat;
+
/**
* Gets the maximum value allowed.
*
@@ -1171,6 +1553,11 @@ declare namespace Xrm
* @remarks Attributes on Quick Create Forms will not save values set with this method.
*/
setValue( value: number ): void;
+
+ /**
+ * A collection of all the controls on the form that interface with this attribute.
+ */
+ controls: Collection.ItemCollection;
}
/**
@@ -1180,6 +1567,20 @@ declare namespace Xrm
*/
export interface StringAttribute extends Attribute
{
+ /**
+ * Gets the attribute format.
+ *
+ * @return The format of the attribute.
+ *
+ * @remarks Values returned are: email
+ * phone
+ * text
+ * textarea
+ * tickersymbol
+ * url
+ */
+ getFormat(): StringAttributeFormat;
+
/**
* Gets maximum length allowed.
*
@@ -1206,6 +1607,11 @@ declare namespace Xrm
* with this method.
*/
setValue( value: string ): void;
+
+ /**
+ * A collection of all the controls on the form that interface with this attribute.
+ */
+ controls: Collection.ItemCollection;
}
/**
@@ -1219,7 +1625,8 @@ declare namespace Xrm
* Gets the initial value of the attribute.
*
* @return The initial value.
- * @remarks Valid for optionset and boolean attribute types
+ *
+ * @remarks Valid for OptionSet and boolean attribute types
*/
getInitialValue(): number | boolean;
}
@@ -1255,6 +1662,16 @@ declare namespace Xrm
*/
export interface DateAttribute extends Attribute
{
+ /**
+ * Gets the attribute format.
+ *
+ * @return The format of the attribute.
+ *
+ * @remarks Values returned are: date
+ * datetime
+ */
+ getFormat(): DateAttributeFormat;
+
/**
* Gets the value.
*
@@ -1270,6 +1687,11 @@ declare namespace Xrm
* @remarks Attributes on Quick Create Forms will not save values set with this method.
*/
setValue( value: Date ): void;
+
+ /**
+ * A collection of all the controls on the form that interface with this attribute.
+ */
+ controls: Collection.ItemCollection;
}
/**
@@ -1279,6 +1701,16 @@ declare namespace Xrm
*/
export interface OptionSetAttribute extends EnumAttribute
{
+ /**
+ * Gets the attribute format.
+ *
+ * @return The format of the attribute.
+ *
+ * @remarks Values returned are: language
+ * timezone
+ */
+ getFormat(): OptionSetAttributeFormat;
+
/**
* Gets the option matching a value.
*
@@ -1336,6 +1768,11 @@ declare namespace Xrm
* with this method.
*/
setValue( value: number ): void;
+
+ /**
+ * A collection of all the controls on the form that interface with this attribute.
+ */
+ controls: Collection.ItemCollection;
}
/**
@@ -1367,6 +1804,11 @@ declare namespace Xrm
* @remarks Attributes on Quick Create Forms will not save values set with this method.
*/
setValue( value: LookupValue[] ): void;
+
+ /**
+ * A collection of all the controls on the form that interface with this attribute.
+ */
+ controls: Collection.ItemCollection;
}
/**
@@ -1447,7 +1889,7 @@ declare namespace Xrm
* @param {string} saveMode (Optional) the save mode to save, as either "saveandclose" or
* "saveandnew".
*/
- save( saveMode: SaveMode | string): void;
+ save( saveMode: SaveMode ): void;
/**
* The collection of attributes for the record.
@@ -1464,6 +1906,7 @@ declare namespace Xrm
* Gets save mode, as an integer.
*
* @return The save mode.
+ *
* @remarks Values returned are: 1 Save
* 2 Save and Close
* 59 Save and New
@@ -1488,6 +1931,7 @@ declare namespace Xrm
/**
* Prevents the save operation from being submitted to the server.
+ *
* @remarks All remaining "on save" handlers will continue execution.
*/
preventDefault(): void;
@@ -1631,6 +2075,7 @@ declare namespace Xrm
* Called when process change methods have completed.
*
* @param {string} status The result of the process change operation.
+ *
* @remarks Values returned are: success (The operation succeeded.)
* crossEntity (The previous stage is for a different entity.)
* beginning (The active stage is the first stage of the active path.)
@@ -1645,29 +2090,19 @@ declare namespace Xrm
*/
export type ProcessDictionary = { [index: string]: string };
}
-
+
/**
* Interface for Xrm.Page.ui controls.
*
* @sa UiElement
*/
- export interface Control extends UiElement, UiFocusable
+ export interface Control extends UiLabelElement, UiCanGetVisibleElement
{
/**
- * Clears the notification identified by uniqueId.
- *
- * @param {string} uniqueId (Optional) Unique identifier.
- *
- * @return true if it succeeds, false if it fails.
- *
- * @remarks If the uniqueId parameter is not used, the current notification shown will be removed.
- */
- clearNotification( uniqueId?: string ): boolean;
-
- /**
- * Gets the control's type.
+ * Gets the controls type.
*
* @return The control type.
+ *
* @remarks Values returned are: standard
* iframe
* lookup
@@ -1677,16 +2112,12 @@ declare namespace Xrm
* notes
* timercontrol
* kbsearch (CRM Online Only, use parature.d.ts)
+ * quickform (see ui.QuickForm)
+ * customcontrol: . (A custom control for mobile phone and tablet clients).
+ * customsubgrid: . (A custom dataset control for mobile phone and tablet clients).
*/
- getControlType(): string;
-
- /**
- * Gets a boolean value, indicating whether the control is disabled.
- *
- * @return true if it is disabled, otherwise false.
- */
- getDisabled(): boolean;
-
+ getControlType(): ControlType | string;
+
/**
* Gets the name of the control on the form.
*
@@ -1711,7 +2142,33 @@ declare namespace Xrm
* @return The parent Section.
*/
getParent(): Section;
-
+ }
+
+ /**
+ * Interface for a standard control.
+ *
+ * @sa Control
+ */
+ export interface StandardControl extends Control, UiStandardElement, UiFocusable
+ {
+ /**
+ * Clears the notification identified by uniqueId.
+ *
+ * @param {string} uniqueId (Optional) Unique identifier.
+ *
+ * @return true if it succeeds, false if it fails.
+ *
+ * @remarks If the uniqueId parameter is not used, the current notification shown will be removed.
+ */
+ clearNotification( uniqueId?: string ): boolean;
+
+ /**
+ * Gets a boolean value, indicating whether the control is disabled.
+ *
+ * @return true if it is disabled, otherwise false.
+ */
+ getDisabled(): boolean;
+
/**
* Sets the state of the control to either enabled, or disabled.
*
@@ -1731,15 +2188,7 @@ declare namespace Xrm
* appears next to the control. Tapping on the icon will display the message.
*/
setNotification( message: string, uniqueId: string ): boolean;
- }
- /**
- * Interface for a standard control.
- *
- * @sa Control
- */
- export interface StandardControl extends Control
- {
/**
* Gets the control's bound attribute.
*
@@ -1758,26 +2207,15 @@ declare namespace Xrm
}
/**
- * Interace for Auto Lookup Control
- * This is not an Entity Lookup, but a control that supports AutoComplete/KeyPress Events (Text)
- * NOTE * This interface is not supported for CRM mobile clients (phones or tablets) and the interactive service hub. It is only available for Updated entities.
+ * Interface for Auto Lookup Control.
+ * This is not an Entity Lookup, but a control that supports AutoComplete / KeyPress Events (Text or Number)
+ *
+ * @remarks This interface is not supported for CRM mobile clients (phones or tablets) and the interactive service hub. It is only available for Updated entities.
*
* @sa StandardControl
*/
- export interface AutoLookupControl extends StandardControl {
- /**
- * Use this to add a function as an event handler for the keypress event so that the function is called when you type a character in the specific text or number field.
- * For a sample JavaScript code that uses the addOnKeyPress method to configure the auto-completion experience, see Sample: Auto-complete in CRM controls.
- *
- * @param {ContextSensitiveHandler} handler The function reference.
- */
- addOnKeyPress(handler: ContextSensitiveHandler): void;
-
- /**
- * Use this to manually fire an event handler that you created for a specific text or number field to be executed on the keypress event.
- */
- fireOnKeyPress(): void;
-
+ export interface AutoLookupControl extends StandardControl, UiKeyPressable
+ {
/**
* Gets the latest value in a control as the user types characters in a specific text or number field.
* This method helps you to build interactive experiences by validating data and alerting users as they type characters in a control.
@@ -1790,15 +2228,7 @@ declare namespace Xrm
* Hides the auto-completion drop-down list configured for a specific text field
*/
hideAutoComplete(): void;
-
- /**
- * Use this to remove an event handler for a text or number field that you added using addOnKeyPress.
- *
- * Remarks: If an anonymous function is set using addOnKeyPress, it can’t be removed using this method.
- * @param {ContextSensitiveHandler} handler The function reference.
- */
- removeOnKeyPress(handler: ContextSensitiveHandler): void;
-
+
/**
* Shows upt to 10 matching strings in a drop-down list as users press keys to type charactrer in a specific text field.
* On selecting an item in the drop-down list, the value in the text field changes to the selected item, the drop-down list disappears, and the OnChange event for the text field is invoked
@@ -1807,6 +2237,36 @@ declare namespace Xrm
showAutoComplete(resultSet: AutoCompleteResultSet): void;
}
+ /**
+ * Interface for a String control.
+ *
+ * @sa StandardControl
+ */
+ export interface StringControl extends AutoLookupControl
+ {
+ /**
+ * Gets the control's bound attribute.
+ *
+ * @return The attribute.
+ */
+ getAttribute(): StringAttribute;
+ }
+
+ /**
+ * Interface for a Number control.
+ *
+ * @sa StandardControl
+ */
+ export interface NumberControl extends AutoLookupControl
+ {
+ /**
+ * Gets the control's bound attribute.
+ *
+ * @return The attribute.
+ */
+ getAttribute(): NumberAttribute;
+ }
+
/**
* Interface for a Date control.
*
@@ -2110,7 +2570,7 @@ declare namespace Xrm
* @sa UiElement
* @sa UiFocusable
*/
- export interface Tab extends UiElement, UiFocusable
+ export interface Tab extends UiStandardElement, UiFocusable
{
/**
* Gets display state of the tab.
@@ -2138,7 +2598,7 @@ declare namespace Xrm
*
* @param {string} displayState Display state of the tab, as either "expanded" or "collapsed"
*/
- setDisplayState(displayState: ui.DisplayState | string ): void;
+ setDisplayState(displayState: ui.DisplayState ): void;
/**
* A reference to the collection of form sections within this tab.
@@ -2151,7 +2611,7 @@ declare namespace Xrm
*
* @sa UiElement
*/
- export interface Section extends UiElement
+ export interface Section extends UiStandardElement
{
/**
* Gets the name of the section.
@@ -2183,14 +2643,14 @@ declare namespace Xrm
*/
export type FormNotificationLevel = "ERROR" | "INFO" | "WARNING";
- /**
+ /**
* Display States for Xrm.ui.ProcessMonitor.setDisplayState().
- */
+ */
export type DisplayState = "collapsed" | "expanded";
- /**
+ /**
* Interface for Xrm.Page.ui.process API
- */
+ */
export interface ProcessManager
{
/**
@@ -2198,7 +2658,7 @@ declare namespace Xrm
*
* @param {string} displayState Display state of the process flow control, as either "expanded" or "collapsed"
*/
- setDisplayState(displayState: ui.DisplayState ): void;
+ setDisplayState( displayState: ui.DisplayState ): void;
/**
* Sets the visibility state.
@@ -2330,7 +2790,7 @@ declare namespace Xrm
}
/**
- * Interface for a view selector item. This object contains data that identifies a view. Use this as a parameter to
+ * Interface for a view selector item. This object contains data that identifies a view. Use this as a parameter to
* the ViewSelector.setCurrentView method.
*/
export interface ViewSelectorItem
@@ -2342,6 +2802,93 @@ declare namespace Xrm
*/
getEntityReference(): LookupValue;
}
+
+ /**
+ * Interface for a quick view control instance on a form.
+ *
+ * @see {@link https://msdn.microsoft.com/en-us/library/mt736908.aspx#bkmk_isLoaded} for details.
+ */
+ export interface QuickForm extends Control, UiLabelElement, UiCanGetVisibleElement
+ {
+ /**
+ * Gets the constituent controls in a quick view control.
+ *
+ * @return An array of controls.
+ *
+ * @remarks Constituent controls in a quick view control are read only.
+ */
+ getControl(): Page.Control[];
+
+ /**
+ * Gets the constituent controls in a quick view control.
+ *
+ * @tparam T A Control type
+ * @param {string} controlName Name of the control.
+ *
+ * @return The control.
+ *
+ * @remarks Constituent controls in a quick view control are read only.
+ */
+ getControl( controlName: string ): T;
+
+ /**
+ * Gets the constituent controls in a quick view control.
+ *
+ * @param {string} controlName Name of the control.
+ *
+ * @return The control.
+ *
+ * @remarks Constituent controls in a quick view control are read only.
+ */
+ getControl( controlName: string ): Page.Control;
+
+ /**
+ * Gets a control by index.
+ *
+ * @tparam T A Control type
+ * @param {number} index The control index.
+ *
+ * @return The control.
+ *
+ * @remarks Constituent controls in a quick view control are read only.
+ */
+ getControl( index: number ): T;
+
+ /**
+ * Gets a control by index.
+ *
+ * @param {number} index The control index.
+ *
+ * @return The control.
+ *
+ * @remarks Constituent controls in a quick view control are read only.
+ */
+ getControl( index: number ): Page.Control;
+
+ /**
+ * Gets the controls type.
+ *
+ * @return Returns a string value that categorizes quick view controls.
+ */
+ getControlType(): ControlQuickFormType;
+
+ /**
+ * Returns whether the data binding for the constituent controls in a quick view control is complete.
+ *
+ * @return True is the data binding for a constituent control is complete, otherwise false.
+ * because the quick view form that the control is bound to may not have loaded completely.
+ * As a result, using the getAttribute or any data-related methods on a constituent control might not work.
+ * The isLoaded method for the quick view control helps determine the data binding status for constituent controls in a quick view control.
+ *
+ * @remarks The data binding for the constituent controls in a quick view control may not be complete during the main form OnLoad event
+ */
+ isLoaded(): boolean;
+
+ /**
+ * Refreshes the data displayed in a quick view control.
+ */
+ refresh(): void;
+ }
}
/**
@@ -2350,7 +2897,7 @@ declare namespace Xrm
* @sa UiElement
* @sa UiFocusable
*/
- export interface NavigationItem extends UiElement, UiFocusable
+ export interface NavigationItem extends UiStandardElement, UiFocusable
{
/**
* Gets the name of the item.
@@ -2427,11 +2974,13 @@ declare namespace Xrm
/**
* Command Bar Display options for Xrm.Url.FormOpenParameters.cmdbar, Xrm.Url.ViewOpenParameters.cmdbar, and Xrm.Utility.FormOpenParameters.cmdbar.
*/
+
export type CmdBarDisplay = "true" | "false";
/**
* Navigation Bar Display options for Xrm.Url.FormOpenParameters.navbar, Xrm.Url.ViewOpenParameters.navbar, and Xrm.Utility.FormOpenParameters.navbar.
*/
export type NavBarDisplay = "entity" | "off" | "on";
+
/**
* Report Open Action options for Xrm.Url.ReportOpenParameters.actions.
*/
@@ -2709,4 +3258,4 @@ declare namespace XrmEnum
SystemView = 1039,
UserView = 4230
}
-}
+}
\ No newline at end of file
diff --git a/xrm/tslint.json b/xrm/tslint.json
new file mode 100644
index 0000000000..0e45822b24
--- /dev/null
+++ b/xrm/tslint.json
@@ -0,0 +1,38 @@
+{
+ "rules": {
+ "class-name": true,
+ "comment-format": [ true, "check-space" ],
+ "indent": [ true, "spaces" ],
+ "no-duplicate-variable": true,
+ "no-eval": true,
+ "no-internal-module": false,
+ "no-trailing-whitespace": false,
+ "no-var-keyword": true,
+ "one-line": [ true, "check-whitespace" ],
+ "quotemark": [ true, "double" ],
+ "semicolon": true,
+ "triple-equals": [ true, "allow-null-check" ],
+ "align": [ true, "parameters", "statements" ],
+ "jsdoc-format": true,
+ "no-consecutive-blank-lines": true,
+ "typedef-whitespace": [
+ true,
+ {
+ "call-signature": "nospace",
+ "index-signature": "nospace",
+ "parameter": "nospace",
+ "property-declaration": "nospace",
+ "variable-declaration": "nospace"
+ }
+ ],
+ "variable-name": [ true, "ban-keywords" ],
+ "whitespace": [
+ true,
+ "check-branch",
+ "check-decl",
+ "check-operator",
+ "check-separator",
+ "check-type"
+ ]
+ }
+}
\ No newline at end of file
diff --git a/xrm/v6/index.d.ts b/xrm/v6/index.d.ts
index 5c624c5f53..fa7ab43463 100644
--- a/xrm/v6/index.d.ts
+++ b/xrm/v6/index.d.ts
@@ -210,10 +210,10 @@ declare namespace Xrm
}
/**
- * Interface for an item collection.
- *
- * @tparam T Generic type parameter.
- */
+ * Interface for an item collection.
+ *
+ * @tparam T Generic type parameter.
+ */
export interface ItemCollection
{
/**
diff --git a/xrm/v6/xrm-tests.ts b/xrm/v6/xrm-tests.ts
index 3b911da94d..45d7cbb567 100644
--- a/xrm/v6/xrm-tests.ts
+++ b/xrm/v6/xrm-tests.ts
@@ -1,13 +1,12 @@
-
function _getContext()
{
- var errorMessage = "Context is not available.";
- if ( typeof GetGlobalContext != "undefined" )
+ const errorMessage = "Context is not available.";
+ if ( typeof GetGlobalContext !== "undefined" )
{ return GetGlobalContext(); }
else
{
- if ( typeof Xrm != "undefined" )
+ if ( typeof Xrm !== "undefined" )
{
return Xrm.Page.context;
}
@@ -15,21 +14,21 @@ function _getContext()
}
}
-var crmContext = _getContext();
+const crmContext = _getContext();
-var grids = Xrm.Page.getControl(( control ) =>
+const grids = Xrm.Page.getControl(( control ) =>
{
return control.getControlType() === "subgrid";
});
-var selectedGridReferences: Xrm.Page.LookupValue[] = [];
+const selectedGridReferences: Xrm.Page.LookupValue[] = [];
grids.forEach(( gridControl: Xrm.Page.GridControl ) =>
{
gridControl.refresh();
});
-var lookupAttribute = Xrm.Page.getControl( "customerid" );
+const lookupAttribute = Xrm.Page.getControl( "customerid" );
lookupAttribute.addCustomFilter( `
@@ -37,7 +36,7 @@ lookupAttribute.addCustomFilter( `
lookupAttribute.addPreSearch(() => { alert( "A search was performed." ); });
-var lookupValues = lookupAttribute.getAttribute().getValue();
+const lookupValues = lookupAttribute.getAttribute().getValue();
if ( lookupValues !== null )
if ( !lookupValues[0].id || !lookupValues[0].entityType )
@@ -57,7 +56,7 @@ Xrm.Page.ui.tabs.forEach(( tab ) =>
Xrm.Page.data.entity.addOnSave(( context ) =>
{
- var eventArgs = context.getEventArgs();
+ const eventArgs = context.getEventArgs();
if ( eventArgs.getSaveMode() === Xrm.Page.SaveMode.AutoSave || eventArgs.getSaveMode() === Xrm.Page.SaveMode.SaveAndClose )
eventArgs.preventDefault();
diff --git a/xrm/v7/index.d.ts b/xrm/v7/index.d.ts
index ee9d45b252..bfe398fd96 100644
--- a/xrm/v7/index.d.ts
+++ b/xrm/v7/index.d.ts
@@ -125,7 +125,7 @@ declare namespace Xrm
* @return An array of control.
*/
getControl( delegateFunction: Collection.MatchingDelegate ): Page.Control[];
- }
+ };
/**
* Provides a container for useful functions not directly related to the current page.
@@ -207,7 +207,7 @@ declare namespace Xrm
* formid
*/
openWebResource( webResourceName: string, webResourceData?: string, width?: number, height?: number ): Window;
- }
+ };
}
/**
@@ -552,10 +552,10 @@ declare namespace Xrm
}
/**
- * Interface for an item collection.
- *
- * @tparam T Generic type parameter.
- */
+ * Interface for an item collection.
+ *
+ * @tparam T Generic type parameter.
+ */
export interface ItemCollection
{
/**
@@ -640,12 +640,12 @@ declare namespace Xrm
export interface Process
{
/**
- * Returns the unique identifier of the process.
- *
- * @return The identifier for this process, in GUID format.
- *
- * @remarks Example: "{825CB223-A651-DF11-AA8B-00155DBA3804}".
- */
+ * Returns the unique identifier of the process.
+ *
+ * @return The identifier for this process, in GUID format.
+ *
+ * @remarks Example: "{825CB223-A651-DF11-AA8B-00155DBA3804}".
+ */
getId(): string;
/**
diff --git a/xrm/v7/parature.d.ts b/xrm/v7/parature.d.ts
index ed9c07921b..7823460843 100644
--- a/xrm/v7/parature.d.ts
+++ b/xrm/v7/parature.d.ts
@@ -3,8 +3,6 @@
// Definitions by: David Berry
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
-
-
declare namespace Xrm.Page
{
/**
diff --git a/xrm/v7/xrm-tests.ts b/xrm/v7/xrm-tests.ts
index 217414feb4..1b82805648 100644
--- a/xrm/v7/xrm-tests.ts
+++ b/xrm/v7/xrm-tests.ts
@@ -9,12 +9,12 @@ parent.Xrm.Page.context.getOrgLcid();
function _getContext()
{
- var errorMessage = "Context is not available.";
- if ( typeof GetGlobalContext != "undefined" )
+ const errorMessage = "Context is not available.";
+ if ( typeof GetGlobalContext !== "undefined" )
{ return GetGlobalContext(); }
else
{
- if ( typeof Xrm != "undefined" )
+ if ( typeof Xrm !== "undefined" )
{
return Xrm.Page.context;
}
@@ -22,16 +22,16 @@ function _getContext()
}
}
-var crmContext = _getContext();
+const crmContext = _getContext();
/// Demonstrate iterator typing
-var grids = Xrm.Page.getControl(( control ) =>
+const grids = Xrm.Page.getControl(( control ) =>
{
return control.getControlType() === "subgrid";
});
-var selectedGridReferences: Xrm.Page.LookupValue[] = [];
+const selectedGridReferences: Xrm.Page.LookupValue[] = [];
/// Demonstrate iterator typing with v7.1 additions
@@ -40,13 +40,13 @@ grids.forEach(( gridControl: Xrm.Page.GridControl ) =>
gridControl.getGrid().getSelectedRows().forEach(( row ) =>
{
selectedGridReferences.push( row.getData().getEntity().getEntityReference() );
- })
+ });
});
/// Demonstrate generic overload vs typecast
-var lookupAttribute = Xrm.Page.getControl( "customerid" );
-var lookupAttribute2 = Xrm.Page.getControl( "customerid" );
+const lookupAttribute = Xrm.Page.getControl( "customerid" );
+const lookupAttribute2 = Xrm.Page.getControl( "customerid" );
/// Demonstrate ES6 String literal syntax
@@ -58,7 +58,7 @@ lookupAttribute.addPreSearch(() => { alert( "A search was performed." ); });
/// Demonstrate strong-typed attribute association with strong-typed control
-var lookupValues = lookupAttribute.getAttribute().getValue();
+const lookupValues = lookupAttribute.getAttribute().getValue();
if ( lookupValues !== null )
if ( !lookupValues[0].id || !lookupValues[0].entityType )
@@ -67,7 +67,7 @@ if ( lookupValues !== null )
/// Demonstrate v7.0 BPF API
if (Xrm.Page.data.process != null)
- Xrm.Page.data.process.moveNext(( status ) => { alert( `Process moved forward with status: ${status}` ) });
+ Xrm.Page.data.process.moveNext(( status ) => { alert( `Process moved forward with status: ${status}` ); });
/// Demonstrate v7.1 Quick Create form
@@ -93,7 +93,7 @@ Xrm.Page.ui.tabs.forEach(( tab ) =>
Xrm.Page.data.entity.addOnSave(( context ) =>
{
- var eventArgs = context.getEventArgs();
+ const eventArgs = context.getEventArgs();
if ( eventArgs.getSaveMode() === XrmEnum.SaveMode.AutoSave || eventArgs.getSaveMode() === XrmEnum.SaveMode.SaveAndClose )
eventArgs.preventDefault();
@@ -107,7 +107,7 @@ alert( `The current entity type is: ${Xrm.Page.data.entity.getEntityName() }` );
/// Demonstrate Optionset Value as int in Turbo Forms
-var optionSetAttribute = Xrm.Page.getAttribute( "statuscode" );
+const optionSetAttribute = Xrm.Page.getAttribute( "statuscode" );
const optionValue: number = optionSetAttribute.getOptions()[0].value;
/// Demonstrate Control.setFocus();
@@ -116,7 +116,7 @@ optionSetAttribute.controls.get(0).setFocus();
/// Demonstrate setFormNotification
-var level: Xrm.Page.ui.FormNotificationLevel;
+let level: Xrm.Page.ui.FormNotificationLevel;
level = "ERROR";
Xrm.Page.ui.setFormNotification("Test", level, "uniqueId");
@@ -132,5 +132,3 @@ attribute.setSubmitMode(submitMode);
attribute.setSubmitMode(submitMode);
attribute.setRequiredLevel(requirementLevel);
attribute.setRequiredLevel(requirementLevelString);
-
-
diff --git a/xrm/xrm-tests.ts b/xrm/xrm-tests.ts
index 1893b9b89a..41f06cbf1e 100644
--- a/xrm/xrm-tests.ts
+++ b/xrm/xrm-tests.ts
@@ -1,6 +1,4 @@
-
-
/// Demonstrate usage in the browser's window object
window.Xrm.Utility.alertDialog( "message", () => {} );
@@ -10,12 +8,12 @@ parent.Xrm.Page.context.getOrgLcid();
function _getContext()
{
- var errorMessage = "Context is not available.";
- if ( typeof GetGlobalContext != "undefined" )
+ const errorMessage = "Context is not available.";
+ if ( typeof GetGlobalContext !== "undefined" )
{ return GetGlobalContext(); }
else
{
- if ( typeof Xrm != "undefined" )
+ if ( typeof Xrm !== "undefined" )
{
return Xrm.Page.context;
}
@@ -23,16 +21,16 @@ function _getContext()
}
}
-var crmContext = _getContext();
+const crmContext = _getContext();
/// Demonstrate iterator typing
-var grids = Xrm.Page.getControl(( control ) =>
+const grids = Xrm.Page.getControl(( control ) =>
{
return control.getControlType() === "subgrid";
});
-var selectedGridReferences: Xrm.Page.LookupValue[] = [];
+const selectedGridReferences: Xrm.Page.LookupValue[] = [];
/// Demonstrate iterator typing with v7.1 additions
@@ -45,8 +43,8 @@ grids.forEach(( gridControl: Xrm.Page.GridControl ) =>
/// Demonstrate generic overload vs typecast
-var lookupAttribute = Xrm.Page.getControl( "customerid" );
-var lookupAttribute2 = Xrm.Page.getControl( "customerid" );
+const lookupAttribute = Xrm.Page.getControl( "customerid" );
+const lookupAttribute2 = Xrm.Page.getControl( "customerid" );
/// Demonstrate ES6 String literal syntax
@@ -58,7 +56,7 @@ lookupAttribute.addPreSearch(() => { alert( "A search was performed." ); });
/// Demonstrate strong-typed attribute association with strong-typed control
-var lookupValues = lookupAttribute.getAttribute().getValue();
+const lookupValues = lookupAttribute.getAttribute().getValue();
if ( lookupValues !== null )
if ( !lookupValues[0].id || !lookupValues[0].entityType )
@@ -67,15 +65,16 @@ if ( lookupValues !== null )
/// Demonstrate v7.0 BPF API
if (Xrm.Page.data.process != null)
- Xrm.Page.data.process.moveNext(( status ) => { alert( `Process moved forward with status: ${status}` ) });
+ Xrm.Page.data.process.moveNext(( status ) => { alert( `Process moved forward with status: ${status}` ); });
/// Demonstrate v7.1 Quick Create form
-Xrm.Utility.openQuickCreate("account").then(( object ) => { if (object) alert( `Newly created record Id: ${object.savedEntityReference.id}` ); }, (error) => {console.log(`Code: ${error.errorCode}, Message: ${error.message}`)});
+Xrm.Utility.openQuickCreate("account").then(( object ) => { if (object) alert( `Newly created record Id: ${object.savedEntityReference.id}` ); }, (error) => {console.log(`Code: ${error.errorCode}, Message: ${error.message}`); });
/// Make all controls visible.
-Xrm.Page.ui.controls.forEach(( control ) => { control.setVisible( true ); });
+// Xrm.Page.ui.controls.forEach(( control ) => { control.setVisible( true ); }); // No longer works
+Xrm.Page.ui.controls.forEach((control: Xrm.Page.StandardControl) => { control.setVisible(true); }); // Must cast to StandardControl
/// Make all tabs and sections visible.
@@ -93,7 +92,7 @@ Xrm.Page.ui.tabs.forEach(( tab ) =>
Xrm.Page.data.entity.addOnSave(( context ) =>
{
- var eventArgs = context.getEventArgs();
+ const eventArgs = context.getEventArgs();
if ( eventArgs.getSaveMode() === XrmEnum.SaveMode.AutoSave || eventArgs.getSaveMode() === XrmEnum.SaveMode.SaveAndClose )
eventArgs.preventDefault();
@@ -107,7 +106,7 @@ alert( `The current entity type is: ${Xrm.Page.data.entity.getEntityName() }` );
/// Demonstrate Optionset Value as int in Turbo Forms
-var optionSetAttribute = Xrm.Page.getAttribute( "statuscode" );
+const optionSetAttribute = Xrm.Page.getAttribute( "statuscode" );
const optionValue: number = optionSetAttribute.getOptions()[0].value;
/// Demonstrate Control.setFocus();
@@ -116,27 +115,27 @@ optionSetAttribute.controls.get(0).setFocus();
/// Demonstrate setFormNotification
-var level: Xrm.Page.ui.FormNotificationLevel;
+let level: Xrm.Page.ui.FormNotificationLevel;
level = "ERROR";
Xrm.Page.ui.setFormNotification("Test", level, "uniqueId");
/// Demonstrate Requirement Level and Submit Mode both via string parameters and String Literal Types
let requirementLevel: Xrm.Page.RequirementLevel = "none";
-let requirementLevelString = "none";
+const requirementLevelString = "none";
let submitMode: Xrm.Page.SubmitMode = "always";
-let submitModeString = "always";
+const submitModeString = "always";
let attribute = Xrm.Page.getAttribute("customerid");
attribute.setSubmitMode(submitMode);
-attribute.setSubmitMode(submitMode);
+attribute.setSubmitMode(submitModeString); // Works if the string is a const
attribute.setRequiredLevel(requirementLevel);
-attribute.setRequiredLevel(requirementLevelString);
+attribute.setRequiredLevel(requirementLevelString); // Works if the string is a const
/// Demonstrate v8 AutoComplete
let autoCompleteControl = Xrm.Page.getControl("name");
-var userInput = autoCompleteControl.getValue();
+const userInput = autoCompleteControl.getValue();
const accountResult = { };
const resultSet: Xrm.Page.AutoCompleteResultSet = {
results: new Array() as Xrm.Page.AutoCompleteResult[],
@@ -164,6 +163,23 @@ autoCompleteControl.removeOnKeyPress(() => {});
autoCompleteControl.showAutoComplete(resultSet);
autoCompleteControl.hideAutoComplete();
+/// Demonstrate v8.2 quick form controls
+const quickForm = Xrm.Page.ui.quickForms.get(0);
+quickForm.getControlType(); // == "quickform"
+quickForm.getName();
+quickForm.getParent();
+quickForm.getVisible(); // From UiCanSetVisibleElement
+quickForm.getLabel(); // From UiLabelElement
+quickForm.setLabel("Label"); // From UiLabelElement
+quickForm.refresh();
-
+// Get standard control
+const ctrl = Xrm.Page.getControl("controlName");
+ctrl.getControlType();
+ctrl.getName();
+ctrl.getParent();
+ctrl.getLabel();
+ctrl.setLabel("Label name");
+ctrl.getVisible();
+ctrl.setVisible(true);