@types/xrm
Version:
TypeScript definitions for xrm
1,150 lines (1,016 loc) • 287 kB
TypeScript
declare var Xrm: Xrm.XrmStatic;
/**
* Gets the global context.
* The method provides access to the global context without going through the form context.
*
* It is preferreed to use {@link Xrm.Utility.getGlobalContext Xrm.Utility.getGlobalContext()} instead.
* @see {@link Xrm.Utility.getGlobalContext}
*/
declare function GetGlobalContext(): Xrm.GlobalContext;
interface Window {
Xrm: Xrm.XrmStatic;
GetGlobalContext(): Xrm.GlobalContext;
}
/**
* Xrm Namespace
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference External Link: Client API Reference}
*/
declare namespace Xrm {
/**
* Static xRM object.
*/
interface XrmStatic {
/**
* Provides a namespace container for the context, data and ui objects.
* @deprecated Deprecated in v9.
* @see {@link https://learn.microsoft.com/en-us/power-platform/important-changes-coming#some-client-apis-are-deprecated External Link: Deprecated Client APIs}
*/
Page: Page;
/** Provides navigation-related methods.
*/
Navigation: Navigation;
/**
* Provides a container for useful functions not directly related to the current page.
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/xrm-utility External Link: Xrm.Utility (Client API reference)}
*/
Utility: Utility;
/**
* Provides methods to create and manage records in the mobile clients (for phones tablets).
* @deprecated Use {@link Xrm.WebApi} instead.
*/
Mobile: Mobile;
/**
* Provides a method to display a web page in the side pane of the Customer Engagement form.
*
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/xrm-panel External Link: Xrm.Panel}
*/
Panel: Panel;
/**
* Provides properties and methods to use Web API to create and manage records and execute Web API actions and functions in Customer Engagement.
*
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/xrm-webapi External Link: Xrm.WebApi (Client API reference)}
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/overview External Link: Use the Microsoft Dataverse Web API}
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/client-scripting External Link: Apply business logic using client scripting in model-driven apps using JavaScript}
*/
WebApi: WebApi;
/**
* Provides methods to use native device capabilities of mobile devices.
*
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/xrm-device External Link: Xrm.Device (Client API reference)}
*/
Device: Device;
/**
* Provides methods to encode strings.
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/xrm-encoding External Link: Xrm.Encoding (Client API reference)}
*/
Encoding: Encoding;
/**
* Provides app-related methods.
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/xrm-app External Link: Xrm.App (Client API reference)}
*/
App: App;
}
/**
* Client Types for {@link ClientContext.getClient clientContext.getClient()}.
* @see {@link XrmEnum.Client}
*/
type Client = "Web" | "Outlook" | "Mobile" | "UnifiedServiceDesk";
/**
* Client States for {@link ClientContext.getClientState clientContext.getClientState()}.
* @see {@link XrmEnum.ClientState}
*/
type ClientState = "Online" | "Offline";
/**
* Display States for setDisplayState() on {@link Controls.ProcessControl.setDisplayState Processes} and {@link Controls.Tab.setDisplayState Tabs}.
* @see {@link XrmEnum.DisplayState}
*/
type DisplayState = "collapsed" | "expanded";
/**
* The {@link Entity.save Entity}'s Save Mode
* @see {@link XrmEnum.EntitySaveMode}
* @see {@link Entity}
* @see {@link Entity.save}
*/
type EntitySaveMode = "saveandclose" | "saveandnew";
/**
* Form Notification Levels for {@link Ui.setFormNotification formContext.ui.setFormNotification()}.
* @see {@link XrmEnum.FormNotificationLevel}
*/
type FormNotificationLevel = "ERROR" | "INFO" | "WARNING";
/**
* App Notification Levels for {@link Xrm.App.addGlobalNotification Xrm.App.addGlobalNotification()}.
* @see {@link XrmEnum.FormNotificationLevel}
*/
type AppNotificationLevel = 1 | 2 | 3 | 4;
/**
* Submit Mode for {@link Attributes.Attribute.setSubmitMode Attributes.Attribute.setSubmitMode()}.
* @see {@link XrmEnum.SubmitMode}
*/
type SubmitMode = "always" | "dirty" | "never";
/**
* Themes for {@link GlobalContext.getCurrentTheme globalContext.getCurrentTheme()}.
* @remarks getCurrentTheme() does not work with Dynamics CRM for tablets or in the unified interface.
* @see {@link XrmEnum.Theme}
*/
type Theme = "default" | "Office12Blue" | "Office14Silver";
/**
* Interface for the client context.
*/
interface ClientContext {
/**
* Returns a value to indicate which client the script is executing in.
* @returns The client, as either "Web", "Outlook", or "Mobile"
*/
getClient(): Client;
/**
* Gets client's current state.
* @returns The client state, as either "Online" or "Offline"
*/
getClientState(): ClientState;
/**
* Use this method to get information about the kind of device the user is using.
*/
getFormFactor(): XrmEnum.ClientFormFactor;
/**
* Returns information whether the server is online or offline.
*/
isOffline(): boolean;
/**
* Returns information whether the network is available or not.
*/
isNetworkAvailable(): boolean;
}
/**
* Returns information about the current organization settings.
*/
interface OrganizationSettings {
/**
* Returns a lookup object containing the ID, name, and entity type of the base currency for the current organization.
*/
baseCurrency: LookupValue;
/**
* Returns the ID of the base currency for the current organization.
* @deprecated Deprecated in v9.1; use {@link Xrm.OrganizationSettings.baseCurrency globalContext.organizationSettings.baseCurrency} instead to display name along with the ID.
*/
baseCurrencyId: string;
/**
* Returns the default country/region code for phone numbers for the current organization.
*/
defaultCountryCode: string;
/**
* Indicates whether the auto-save option is enabled for the current organization.
*/
isAutoSaveEnabled: boolean;
/**
* Returns the preferred language ID for the current organization.
*/
languageId: number;
/**
* Returns the ID of the current organization.
*/
organizationId: string;
/**
* Returns the unique name of the current organization.
*/
uniqueName: string;
/**
* Indicates whether the Skype protocol is used for the current organization.
*/
useSkypeProtocol: boolean;
/**
* Returns the region of the current organization.
* @see {@link https://learn.microsoft.com/en-us/power-platform/admin/geo-to-geo-migrations External Link: Geo to geo migrations}
*/
organizationGeo: string;
}
/**
* Interface for the {@link DateFormattingInfo DateFormattingInfo.calendar} field
*/
interface Calendar {
MinSupportedDateTime: Date;
MaxSupportedDateTime: Date;
AlgorithmType: number;
CalendarType: number;
Eras: number[];
TwoDigitYearMax: number;
IsReadOnly: boolean;
}
/**
* Interface for {@link UserSettings UserSettings.dateFormattingInfo} response
*/
interface DateFormattingInfo {
AmDesignator: string;
AbbreviatedDayNames: string[];
AbbreviatedMonthGenitiveNames: string[];
AbbreviatedMonthNames: string[];
CalendarWeekRule: number;
Calendar: Calendar;
DateSeparator: string;
DayNames: string[];
FirstDayOfWeek: number;
FullDateTimePattern: string;
LongDatePattern: string;
LongTimePattern: string;
MonthDayPattern: string;
MonthGenitiveNames: string[];
MonthNames: string[];
PmDesignator: string;
ShortDatePattern: string;
ShortTimePattern: string;
ShortestDayNames: string[];
SortableDateTimePattern: string;
TimeSeparator: string;
UniversalSortableDateTimePattern: string;
YearMonthPattern: string;
}
/**
* Holds information about the current user settings.
*/
interface UserSettings {
/**
* Returns the date formatting information for the current user.
*/
dateFormattingInfo: DateFormattingInfo;
/**
* Returns the ID of the default dashboard for the current user.
*/
defaultDashboardId: string;
/**
* Indicates whether guided help is enabled for the current user.
*/
isGuidedHelpEnabled: boolean;
/**
* Indicates whether high contrast is enabled for the current user.
*/
isHighContrastEnabled: boolean;
/**
* Indicates whether the language for the current user is a right-to-left (RTL) language.
*/
isRTL: boolean;
/**
* Returns the language ID for the current user.
*/
languageId: number;
/**
* Returns a collection of lookup objects containing the GUID and display name of each of the security role or teams that the user is associated with.
*/
roles: Collection.ItemCollection<LookupValue>;
/**
* Returns an array of strings that represent the GUID values of each of the security role privilege that the user is associated with or any teams that the user is associated with.
*/
securityRolePrivileges: string[];
/**
* Returns an array of strings that represent the GUID values of each of the security role that the user is associated with or any teams that the user is associated with.
* @deprecated Deprecated in v9.1; use {@link Xrm.UserSettings.roles globalContext.userSettings.roles} instead to display names of security roles or teams along with the ID.
* @see {@link https://learn.microsoft.com/en-us/power-platform/important-changes-coming#some-client-apis-are-deprecated External Link: Deprecated Client APIs}
*/
securityRoles: string[];
/**
* Returns a lookup object containing the ID, display name, and entity type of the transaction currency for the current user.
*/
transactionCurrency: LookupValue;
/**
* Returns the transaction currency ID for the current user.
* @deprecated Deprecated in v9.1; use {@link Xrm.UserSettings.transactionCurrency globalContext.userSettings.transactionCurrency} instead to display name along with the ID.
*/
transactionCurrencyId: string;
/**
* Returns the GUID of the SystemUser.Id value for the current user.
*/
userId: string;
/**
* Returns the name of the current user.
*/
userName: string;
/**
* Returns the difference in minutes between the local time and Coordinated Universal Time (UTC).
*/
getTimeZoneOffsetMinutes(): number;
}
/**
* properties of the current business app in Customer Engagement.
*/
interface AppProperties {
appId?: string | undefined;
displayName?: string | undefined;
uniqueName?: string | undefined;
url?: string | undefined;
webResourceId?: string | undefined;
webResourceName?: string | undefined;
welcomePageId?: string | undefined;
welcomePageName?: string | undefined;
}
/**
* Interface for the xRM application context.
* @see {@link GetGlobalContext GetGlobalContext()}
*/
interface GlobalContext {
/**
* The client's context instance.
*/
client: ClientContext;
/**
* Returns information about the current organization settings.
*/
organizationSettings: OrganizationSettings;
/**
* Returns information about the current user settings.
*/
userSettings: UserSettings;
/**
* Returns information about the advanced configuration settings for the organization.
* @param setting Name of the configuration setting.
* @see {@link XrmEnum.AdvancedConfigSettingOption}
*/
getAdvancedConfigSetting(setting: "MaxChildIncidentNumber" | "MaxIncidentMergeNumber"): number;
/**
* Gets client's base URL for Dynamics CRM
* @returns The client's base URL
* @example
* // 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
*/
getClientUrl(): string;
/**
* Returns the name of the current business app in Customer Engagement.
*/
getCurrentAppName(): Async.PromiseLike<string>;
/**
* Returns the properties of the current business app in Customer Engagement.
*/
getCurrentAppProperties(): Async.PromiseLike<AppProperties>;
/**
* Returns the URL of the current business app in Customer Engagement.
* @example
* // Online https://**org**.crm.dynamics.com/main.aspx?appid=**GUID**
* // OnPrem https://**server**\/**org**\/main.aspx?appid=**GUID**
* @returns A string containing the url of the current business app.
*/
getCurrentAppUrl(): string;
/**
* Gets current styling theme.
* @remarks This function does not work with Dynamics CRM for tablets or in the unified interface.
* @returns The name of the current theme, as either "default", "Office12Blue", or "Office14Silver"
*/
getCurrentTheme(): Theme;
/**
* Gets whether automatic save is enabled.
* @deprecated Deprecated in v9. Use {@link Xrm.OrganizationSettings.isAutoSaveEnabled globalContext.organizationSettings.isAutoSaveEnabled} instead.
* @see {@link https://learn.microsoft.com/en-us/power-platform/important-changes-coming#some-client-apis-are-deprecated External Link: Deprecated Client APIs}
* @returns true if automatic saving is enabled, otherwise false.
*/
getIsAutoSaveEnabled(): boolean;
/**
* Gets organization's LCID (language code).
* @deprecated Deprecated in v9. Use {@link Xrm.OrganizationSettings.languageId globalContext.organizationSettings.languageId} instead.
* @see {@link https://learn.microsoft.com/en-us/power-platform/important-changes-coming#some-client-apis-are-deprecated External Link: Deprecated Client APIs}
* @returns The organization language code.
* @see {@link https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/available-language-packs-for-windows External Link: Microsoft Locale ID Values}
*/
getOrgLcid(): number;
/**
* Gets organization's unique name.
* @remarks This value can be found on the Developer Resources page within Dynamics CRM.
* @deprecated Deprecated in v9. Use {@link Xrm.OrganizationSettings.uniqueName} globalContext.organizationSettings.uniqueName instead.
* @see {@link https://learn.microsoft.com/en-us/power-platform/important-changes-coming#some-client-apis-are-deprecated External Link: Deprecated Client APIs}
* @returns The organization's unique name.
*/
getOrgUniqueName(): string;
/**
* Gets query string parameters.
* @returns The query string parameters, in a dictionary object representing name and value pairs.
* @deprecated Deprecated in v9 (Still applicable in Web Client).
* @see {@link https://learn.microsoft.com/en-us/power-platform/important-changes-coming#some-client-apis-are-deprecated External Link: Deprecated Client APIs}
*/
getQueryStringParameters(): { [index: string]: any };
/**
* Returns the difference between the local time and Coordinated Universal Time (UTC).
* @returns The time zone offset, in minutes.
*/
getTimeZoneOffsetMinutes(): number;
/**
* Gets user's unique identifier.
* @deprecated Deprecated in v9. Use {@link Xrm.UserSettings.userId globalContext.userSettings.userId} instead.
* @see {@link https://learn.microsoft.com/en-us/power-platform/important-changes-coming#some-client-apis-are-deprecated External Link: Deprecated Client APIs}
* @returns The user's identifier in Guid format.
* @example Example: "{B05EC7CE-5D51-DF11-97E0-00155DB232D0}"
*/
getUserId(): string;
/**
* Gets user's LCID (language code).
* @deprecated Deprecated in v9. Use {@link Xrm.UserSettings.languageId globalContext.userSetings.languageId} instead.
* @see {@link https://learn.microsoft.com/en-us/power-platform/important-changes-coming#some-client-apis-are-deprecated External Link: Deprecated Client APIs}
* @returns The user's language code.
* @see {@link https://learn.microsoft.com/en-us/previous-versions/windows/embedded/ms912047(v=winembedded.10) External Link: Microsoft Locale ID Values}
*/
getUserLcid(): number;
/**
* Gets the name of the current user.
* @deprecated Deprecated in v9. Use {@link Xrm.UserSettings.userName globalContext.userSettings.userName} instead.
* @see {@link https://learn.microsoft.com/en-us/power-platform/important-changes-coming#some-client-apis-are-deprecated External Link: Deprecated Client APIs}
* @returns The user's name.
*/
getUserName(): string;
/**
* Gets all user security roles.
* @deprecated Deprecated in v9. Use {@link Xrm.UserSettings.roles globalContext.userSettings.roles} instead.
* @see {@link https://learn.microsoft.com/en-us/power-platform/important-changes-coming#some-client-apis-are-deprecated External Link: Deprecated Client APIs}
* @returns An array of user role identifiers, in Guid format.
* @example Example: ["cf4cc7ce-5d51-df11-97e0-00155db232d0"]
*/
getUserRoles(): string[];
/**
* Returns the version number of the Dynamics 365 server.
* @returns The version number
*/
getVersion(): string;
/**
* Returns a boolean value indicating if the Customer Engagement instance is hosted on- premises or online.
*/
isOnPremise(): boolean;
/**
* Prefixes the current organization's unique name to a string; typically a URL path.
* @param sPath Local pathname of the resource.
* @returns A path string with the organization name. Format: "/"+ OrgName + sPath
*/
prependOrgName(sPath: string): string;
/**
* Gets the current value of a settings row.
* @param settingName Name of the setting youd like to receive the value from.
* @returns The current value of the setting.
*/
getCurrentAppSetting(settingName: string): string | number | boolean;
/**
* Returns the relative URL with the caching token for the specified web resource.
* @param webResourceName Name of the web resource.
* @returns The relative URL, including the caching token, for the specified web resource.
*/
getWebResourceUrl(webResourceName: string): string;
}
/**
* Interface for value returned from {@link Xrm.Utility.getPageContext Xrm.Utility.getPageContext()}
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/xrm-utility/getpagecontext#returns External Link: getPageContext (Client API reference)}
*/
interface PageContext {
input: EntityFormPageContext | EntityListPageContext;
}
/**
* Interface for `input` property of returned value from {@link Xrm.Utility.getPageContext Xrm.Utility.getPageContext()}
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/xrm-utility/getpagecontext#entity-form External Link: getPageContext (Client API reference)}
*/
interface EntityFormPageContext {
/**
* The current page type.
*/
pageType: "entityrecord";
/**
* Logical name of the entity currently displayed.
*/
entityName: string;
/**
* ID of the entity record currently displayed in the form.
*/
entityId?: string | undefined;
/**
* The parent record that provides default values based on mapped attribute values.
*/
createFromEntity?: LookupValue | undefined;
/**
* ID of the currently displayed form.
*/
formId?: string | undefined;
}
/**
* Interface for `input` property of returned value from {@link Xrm.Utility.getPageContext Xrm.Utility.getPageContext()}
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/xrm-utility/getpagecontext#entity-list External Link: getPageContext (Client API reference)}
*/
interface EntityListPageContext {
/**
* The current page type.
*/
pageType: "entitylist";
/**
* Logical name of the entity currently displayed.
*/
entityName: string;
/**
* ID of the view currently displayed.
*/
viewId?: string | undefined;
/**
* Type of the view currently displayed.
*/
viewType?: "savedquery" | "userquery" | undefined;
}
/**
* <CrmParameter> used in RibbonDiffXml actions
* @see {@link https://learn.microsoft.com/en-us/previous-versions/dynamicscrm-2016/developers-guide/gg309332(v=crm.8) External Link: <CrmParameter> (RibbonDiffXml)}
*/
interface CommandProperties {
/**
* The Id value of the Ribbon control that initiated the event.
*/
SourceControlId: string;
/**
* A string that is sent with the command event when a button is clicked.
*/
CommandValueId: string;
/**
* A reference from a control to the Id of a menu item.
*
* Most entities will not return a MenuItemId value. Only the following entities will return this value:
* - BusinessUnit
* - Connection
* - CustomerAddress
* - Equipment
* - Goal
* - InvoiceDetail
* - Mailbox
* - MailMergeTemplate
* - PartnerApplication
* - QueueItem
* - QuoteDetail
* - RoutingRuleItem
* - SalesOrderDetail
* - ServiceAppointment
* - SharePointDocumentLocation
* - SharePointSite
* - Territory
*/
MenuItemId: string;
}
/**
* Some <CrmParameter> values pass an EntityReference object:
* SelectedControlSelectedItemReferences
* SelectedControlAllItemReferences
* SelectedControlUnselectedItemReferences
*
* Not to be confused with the more commonly used {@link Xrm.LookupValue LookupValue }.
*
* @see {@link https://learn.microsoft.com/en-us/previous-versions/dynamicscrm-2016/developers-guide/gg309332(v=crm.8)#remarks External Link: CrmParameter Remarks}
*/
interface EntityReference {
/**
* A string of the GUID Id value for the record.
*/
Id: string;
/**
* A string of the value of the Primary field for the record.
*/
Name: string;
/**
* A string representing the unique name of the entity for the record.
*/
TypeName: string;
/**
* @deprecated Use {@link TypeName} instead. The number value for custom entities will typically be different from organization to organization and the number value cannot be used reliably for custom entities.
*/
TypeCode: number;
}
namespace Events {
/**
* Interface for save event arguments.
*/
interface SaveEventArguments {
/**
* @summary Gets save mode, as an integer.
* @returns The save mode.
* @description Gets save mode, as an integer.<BR>
* **Values returned are**:
* * 1 Save
* * 2 Save and Close
* * 59 Save and New
* * 70 AutoSave (Where enabled; can be used with an OnSave handler to conditionally disable auto-saving)
* * 58 Save as Completed (Activities)
* * 5 Deactivate
* * 6 Reactivate
* * 47 Assign (All user- or team-owned entities)
* * 7 Send (Email)
* * 16 Qualify (Lead)
* * 15 Disqualify (Lead)
*/
getSaveMode(): XrmEnum.SaveMode;
/**
* Returns a boolean value to indicate if the record's save has been prevented.
* @returns true if saving is prevented, otherwise false.
*/
isDefaultPrevented(): boolean;
/**
* Prevents the save operation from being submitted to the server.
* All remaining "on save" handlers will continue execution.
*/
preventDefault(): void;
/**
* 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 SaveEventArgumentsAsync extends SaveEventArguments {
/**
* @summary Call to prevent default 10 second timeout in async OnSave event handlers.
* @description When using an async save the handler will wait for the promise to be fulfilled.
* To ensure that a save completes in a timely manner the handler throws a timeout exception after
* 10 seconds to let you know to tune the async OnSave event for better performance. When the
* disableAsyncTimeout is set, the timeout for that handler will not be applied. It will continue
* to wait for that handler's promise to be fulfilled.
* This should be used with caution as it might affect the performance of the form save.
* @see {@link https://learn.microsoft.com/power-apps/developer/model-driven-apps/clientapi/reference/events/form-onsave#async-onsave-timeouts External Link: Async onSave timeouts}
*/
disableAsyncTimeout(): void;
}
/**
* Interface for postsave event arguments
*/
interface PostSaveEventArguments {
/**
* Use this method to know information about a table being saved.
* It returns the table logical name, record ID, and table name if save was successful.
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/save-event-arguments/getentityreference}
*/
getEntityReference(): LookupValue;
/** Use this method to know whether the save operation was successful or failed.
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/save-event-arguments/getissavesuccess}
*/
getIsSaveSuccess(): boolean;
/**
* Use this method to know the error details on why save failed.
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/save-event-arguments/getsaveerrorinfo}
*/
getSaveErrorInfo(): object;
}
/**
* Interface for process stage change event arguments.
*/
interface StageChangeEventArguments {
/**
* Gets the direction of the stage change.
* @returns The direction: "next" or "previous"
*/
getDirection(): ProcessFlow.StageChangeDirection;
/**
* Gets the destination stage object
* @returns The stage object. For switching between entities, returns the previous stage object
*/
getStage(): ProcessFlow.Stage;
/**
* Prevents the stage or status change operation from being submitted to the server.
*/
preventDefault(): void;
}
/**
* Interface for process stage selected event arguments.
*/
interface StageSelectedEventArguments {
/**
* Gets the selected stage object
* @returns The stage object
*/
getStage(): ProcessFlow.Stage;
}
/**
* Interface for process status changed event arguments.
*/
interface ProcessStatusChangedEventArguments {
/**
* Gets the selected stage object
* @returns The stage object
*/
getStage(): ProcessFlow.Stage;
/**
* Gets the destination process status
* @returns The process status
*/
getStatus(): ProcessFlow.ProcessStatus;
/**
* Prevents the stage or status change operation from being submitted to the server.
*/
preventDefault(): void;
}
interface LookupTagClickEventArguments {
/**
* Gets the selected tag value
* @returns The lookups TagValue object
*/
getTagValue(): TagValue;
/**
* Prevents the default onClick behaviour from executing.
* All remaining "onLookupTagClick" handlers will continue execution.
*/
preventDefault(): void;
/**
* Returns a boolean value to indicate if the lookups onClick has been prevented.
* @returns true if saving is prevented, otherwise false.
*/
isDefaultPrevented(): boolean;
}
/**
* Interface for the event context.
* In the API documentation, this is sometimes referred to as the executionContext.
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/clientapi-execution-context?tabs=pass-execution-context-legacy External Link: Client API execution context}
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/execution-context External Link: Execution context (Client API reference)}
*/
interface EventContext {
/**
* Gets the Xrm context.
* @returns The {@link GlobalContext Xrm context}
*/
getContext(): GlobalContext;
/**
* Gets the handler's depth, which is the order in which the handler is executed.
* @returns The depth, a 0-based index.
*/
getDepth(): number;
/**
* Gets a reference to the object for which event occurred.
* @returns The event source.
*/
getEventSource(): Attributes.Attribute | Controls.Control | Entity;
/**
* Gets a reference to the current form context
* @returns The {@link FormContext form context}
*/
getFormContext(): FormContext;
/**
* @summary Gets the shared variable with the specified key.
* @param T Generic type parameter.
* @param key The key.
* @returns The shared variable.
* @description Gets the shared variable with the specified key.
* Used to pass values between handlers of an event.
*/
getSharedVariable<T>(key: string): T;
/**
* @summary Sets a shared variable.
* @param T Generic type parameter.
* @param key The key.
* @param value The value.
* @description Sets the shared variable with the specified key.
* Used to pass values between handlers of an event.
*/
setSharedVariable<T>(key: string, value: T): void;
}
/**
* Form Data OnLoad event context.
* In the API documentation, this is sometimes referred to as the executionContext.
* Subscribe to this event with {@link Data.addOnLoad()}
* Not to be confused with {@link LoadEventContext}, registered in the designer.
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/execution-context External Link: Execution context (Client API reference)}
*/
interface DataLoadEventContext extends EventContext {
/**
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/executioncontext/geteventargs#return-value External Link: getEventArgs (Client API reference)}
*/
getEventArgs(): DataLoadEventArguments;
}
/**
* Return value of {@link DataLoadEventContext.getEventArgs()}
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/executioncontext/geteventargs#return-value External Link: getEventArgs (Client API reference)}
*/
interface DataLoadEventArguments {
getDataLoadState(): XrmEnum.FormDataLoadState;
}
/**
* Synchronous Form OnLoad event context.
* In the API documentation, this is sometimes referred to as the executionContext.
* Asynchronous version see {@link LoadEventContextAsync}
* Not to be confused with {@link DataLoadEventContext}
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/events/form-onsave#asynchronous-event-handler-support External Link: Form OnSave event: Asynchronous event handler support}
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/execution-context External Link: Execution context (Client API reference)}
*/
interface LoadEventContext extends EventContext {
/**
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/executioncontext/geteventargs#return-value External Link: getEventArgs (Client API reference)}
*/
getEventArgs(): LoadEventArguments;
}
/**
* Return value of {@link LoadEventContext.getEventArgs()}
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/executioncontext/geteventargs#return-value External Link: getEventArgs (Client API reference)}
*/
interface LoadEventArguments {
getDataLoadState(): XrmEnum.FormDataLoadState;
}
/**
* Asynchronous Form OnLoad event context.
* In the API documentation, this is sometimes referred to as the executionContext.
* Synchronous version see {@link LoadEventContext}
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/events/form-onsave#asynchronous-event-handler-support External Link: Form OnSave event: Asynchronous event handler support}
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/execution-context External Link: Execution context (Client API reference)}
*/
interface LoadEventContextAsync extends LoadEventContext {
getEventArgs(): LoadEventArgumentsAsync;
}
interface LoadEventArgumentsAsync extends LoadEventArguments {
/**
* @summary Call to prevent default 10 second timeout in async OnLoad event handlers.
* @description When using an async load the handler will wait for the promise to be fulfilled.
* To ensure that a load completes in a timely manner the handler throws a timeout exception after
* 10 seconds to let you know to tune the async OnLoad event for better performance. When the
* disableAsyncTimeout is set, the timeout for that handler will not be applied. It will continue
* to wait for that handler's promise to be fulfilled.
* This should be used with caution as it might affect the performance of the form load.
* @see {@link https://learn.microsoft.com/power-apps/developer/model-driven-apps/clientapi/reference/events/form-onload#async-onload-timeouts External Link: Async onLoad timeouts}
*/
disableAsyncTimeout(): void;
}
/**
* Synchronous Form OnSave event context.
* In the API documentation, this is sometimes referred to as the executionContext.
* Asynchronous version see {@link SaveEventContextAsync}
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/events/form-onsave External Link: Form OnSave event}
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/execution-context External Link: Execution context (Client API reference)}
*/
interface SaveEventContext extends EventContext {
/**
* Gets save-event arguments.
*/
getEventArgs(): SaveEventArguments;
}
/**
* Asynchronous Form OnSave event context.
* In the API documentation, this is sometimes referred to as the executionContext.
* Synchronous version see {@link SaveEventContext}
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/events/form-onsave#asynchronous-event-handler-support External Link: Form OnSave event: Asynchronous event handler support}
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/execution-context External Link: Execution context (Client API reference)}
*/
interface SaveEventContextAsync extends SaveEventContext {
getEventArgs(): SaveEventArgumentsAsync;
}
/**
* Synchronous Form OnPostSave event context.
* In the API documentation, this is sometimes referred to as the executionContext.
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/save-event-arguments External Link: Form OnPostSave event}
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/execution-context External Link: Execution context (Client API reference)}
*/
interface PostSaveEventContext extends EventContext {
/**
* Gets postsave-event arguments.
*/
getEventArgs(): PostSaveEventArguments;
}
/**
* Interface for a process stage change event context
*/
interface StageChangeEventContext extends EventContext {
/**
* Gets process stage change event arguments.
* @returns The event arguments.
*/
getEventArgs(): StageChangeEventArguments;
}
interface StageSelectedEventContext extends EventContext {
/**
* Gets process stage selected event arguments.
* @returns The event arguments.
*/
getEventArgs(): StageSelectedEventArguments;
}
interface ProcessStatusChangedEventContext extends EventContext {
/**
* Gets process status changed event arguments.
* @returns The event arguments.
*/
getEventArgs(): ProcessStatusChangedEventArguments;
}
interface LookupTagClickEventContext extends EventContext {
/**
* Gets an object that contains details about the lookup tag clicked
*/
getEventArgs(): LookupTagClickEventArguments;
}
/**
* Type for a context-sensitive handler.
* @param context The context.
*/
type ContextSensitiveHandler = (context: EventContext) => void;
type LoadEventHandler = (context: LoadEventContext) => void;
type LoadEventHandlerAsync = (context: LoadEventContextAsync) => void;
type DataLoadEventHandler = (context: DataLoadEventContext) => void;
type SaveEventHandler = (context: SaveEventContext) => void;
type SaveEventHandlerAsync = (context: SaveEventContextAsync) => PromiseLike<void>;
type PostSaveEventHandler = (context: PostSaveEventContext) => void;
type ProcessStatusChangeHandler = (context: ProcessStatusChangedEventContext) => void;
type StageChangeEventHandler = (context: StageChangeEventContext) => void;
type StageSelectedEventHandler = (context: StageSelectedEventContext) => void;
type LookupTagClickHandler = (context: LookupTagClickEventContext) => void;
namespace Attribute {
type ChangeEventHandler = (context: ChangeEventContext) => void;
interface ChangeEventContext extends EventContext {}
}
namespace GridControl {
type LoadEventHandler = (context: LoadEventContext) => void;
interface LoadEventContext extends EventContext {}
}
namespace KbSearchControl {
type PostSearchEventHandler = (context: PostSearchEventContext) => void;
interface PostSearchEventContext extends EventContext {}
type ResultOpenedEventHandler = (context: ResultOpenedEventContext) => void;
interface ResultOpenedEventContext extends EventContext {}
type SelectionEventHandler = (context: SelectionEventContext) => void;
interface SelectionEventContext extends EventContext {}
}
}
/**
* Defines save options for saving the record.
*
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/formcontext-data/save External Link: save(Client API reference)}
*/
interface SaveOptions {
/**
* Specify a value indicating how the save event was initiated.
* @remarks
* For a list of supported values, see the return value of the {@link Xrm.Events.SaveEventArguments.getSaveMode getSaveMode} method.
*
* Note that setting the saveMode does not actually take the corresponding action; it is just to provide information to the OnSave event handlers about the reason for the save operation.
*/
saveMode: XrmEnum.SaveMode;
/**
* 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.
* @remarks This property is not supported in Unified Interface.
*/
UseSchedulingEngine?: boolean | undefined;
}
/**
* Interface for the {@link Xrm.FormContext.data formContext.data} object.
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/formcontext-data External Link: formContext.data (Client API reference)}
*/
interface Data {
/**
* Adds a function to be called when form data is loaded.
* @param handler The function to be executed when the form data loads. The function will be added to the bottom of the event handler pipeline.
*/
addOnLoad(handler: Events.DataLoadEventHandler): void;
/**
* Gets a boolean value indicating whether the form data has been modified.
* @returns Returns true if the form data has changed; false otherwise.
*/
getIsDirty(): boolean;
/**
* Gets a boolean value indicating whether all of the form data is valid. This includes the main entity and any unbound attributes.
* @returns Returns true if all of the form data is valid; false otherwise.
*/
isValid(): boolean;
/**
* Asynchronously refreshes data on the form, without reloading the page.
* @param save true to save the record, after the refresh.
* @returns Returns an asynchronous promise.
*/
refresh(save: boolean): Async.PromiseLike<undefined>;
/**
* Removes a function to be called when form data is loaded.
* @param handler The function to be removed when the form data loads.
*/
removeOnLoad(handler: Events.ContextSensitiveHandler): void;
/**
* Asynchronously saves the record.
* @returns Returns an asynchronous promise.
*/
save(): Async.PromiseLike<undefined>;
/**
* Asynchronously saves the record with the option to set callback functions to be executed after the save operation is completed.
* @param saveOptions Options to control how appointment, recurring appointment, or service activity records are processed.
* @returns Returns an asynchronous promise.
*/
save(saveOptions: SaveOptions): Async.PromiseLike<undefined>;
/**
* Collection of non-entity data on the form.
* Items in this collection are of the same type as the attributes collection, but they are not attributes of the form entity.
* In V9 this is only available in the Unified Client
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/attributes External Link: Attributes (Client API reference)}
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/collections External Link: Collections (Client API reference)}
* @see {@link Attributes}
*/
attributes: Collection.ItemCollection<Attributes.Attribute>;
/**
* The record context of the form
* @see {@link Entity formContext.data.entity}
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/formcontext-data-entity External Link: formContext.data.entity (Client API reference)}
*/
entity: Entity;
/**
* The process API for {@link ProcessFlow.ProcessManager formContext.ui.process}.
* @remarks This member may be undefined when Process Flows are not used by the current entity.
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/formcontext-data-process External Link: formContext.data.process (Client API reference)}
*/
process: ProcessFlow.ProcessManager;
}
/**
* Interface for {@link Xrm.Events.EventContext.getFormContext formContext}
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/executioncontext/getformcontext External Link: getFormContext (Client API reference)}
*/
interface FormContext {
/**
* Provides methods to work with the form.
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/formcontext-data External Link: formContext.data (Client API reference)}
*/
data: Data;
/**
* Contains properties and methods to retrieve information about the user interface as well as collections for several subcomponents of the form.
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/formcontext-ui External Link: formContext.ui (Client API reference)}
*/
ui: Ui;
/**
* Gets an attribute