/// export * from "./getXrmP"; import { XRM } from "./xrm"; /** * Get a URL parameter from `search` or `document.loction.search` by * default. This is useful for obtaining the "data" parameter from the URL * that is passed in from a form if you set the WebResource url properties. * Sometimes the API does not seem to work, but this seems to always work. */ export declare function getURLParameter(name: string, search?: string): string | null; /** Generate a unique id with an optional prefix. */ export declare function generateId(prefix?: string): string; /** Probably need something multi-browser friendly here. */ export declare function uuidv4(): string; /** Uses internal API. */ export declare function isUci(xrm: XRM): boolean; /** Return true if we are running inside electron. */ export declare function isElectron(): boolean; /** * Checks the form context to see if there is an entity id. If not, * it's probably a new form. */ export declare function hasEntityId(xrm: XRM | null): boolean; /** Return the entity id on the page context or null. Braces removed. */ export declare function entityIdOrNull(xrm: XRM | null): string | null; /** * After a save event, run actionToTake if ready returns ture. Uses polling. * Once actionToTake is run, the polling is removed. An exception thrown in * in ready is considered a false return. * @param xrm Xrm to attach to Xrm.Page.data.entity.addOnSave/removeOnSave * @param ready Return true if the condition to run actionToTake has been met. * @param actionToTake The action to take. * @param pollInterval The interval to poll that ready is true after the save has occurred. * @return A cancellable thunk. */ export declare function runAfterSave(xrm: XRM, ready: (x?: XRM) => boolean | null | undefined, actionToTake: (x?: XRM) => void, pollInterval?: number): () => void; /** Render a null, which in react means no rendering. */ export declare const RenderNothing: () => null; /** Do nothing. */ export declare function noop(): void; /** * If cb is a function, return it, otherwise noop. * @param cb Callback */ export declare function callbackOrNoop(cb: any): any; /** * If arg is an array, return the first element if it exists, * otherwise, return other. */ export declare function firstOrElse(arg: any, other: any): any; /** Find the first undefined array element or return undefined. */ export declare function firstUndefined(...args: any[]): any; /** * Execute fns with the same args in order until * `event.preventDefault()` is called. This is really * just a takeWhile and map where "event" is mutable state. */ export declare function composeEventHandlers(...fns: any[]): (event: any, ...args: any[]) => void; /** Per downshift, (p)react. */ export declare function isDOMElement(el: any): boolean; /** Return true if its a number. */ export declare function isNumber(thing: any): boolean; /** * Get props for (p)react. */ export declare function getElementProps(element: any): any; /** * Return the parent's Xrm from window.parent.Xrm or window.Xrm. * No check to see if Xrm.Page.data is present as that is deprecated. * This is a strict value check, no async. * * @see getXrmForEntity */ export declare function getXrm(): XRM | null; /** * Return the global context from GetGlobalContext(), then * Xrm.Utility.getGlobalContext() then Xrm.Page.context. * Throws Error if not found. * * @see https://msdn.microsoft.com/pt-pt/library/af74d417-1359-4eaa-9f87-5b33a8852e83(v=crm.7) */ export declare function getGlobalContext(): Xrm.GlobalContext; /** * Walk the window chain looking for Xrm with Xrm.Page.data attribute being * non-null. Return null if not found. It will walk the window hierarchy * as well as test some well known locations of Xrm. * * @see getXrm */ export declare function getXrmForEntity(): XRM | null; /** * Run a thunk up the window chain. Return the last window visited if it meets * select criteria (if provided) or if select returns true for a particular * window. Return null otherwise. Thunk is usually used for logging. */ export declare function walkParents({thunk, select, max}: { thunk?: (w: Window) => void; select: (w: Window) => boolean; max?: number; }): Window | null; /** * Try to get entityid, userid, entity name, entity type code (number) from a * variety of places including the Xrm values and the URL parameters in the * document that the function is called from. Varibles that are found are * returned but if something is not found it is not returned. If its a new * entity, obviously, the entityid will not be present. Return an object with * {userId, entityId, entityName, entityTypeCode}. Note that entityTypeCode * is specific to an organization so do not use it if you can avoid it. * * Should typecode be number or string? */ export declare function getEntityInfo(xrm?: XRM | null): { userId?: string; entityId?: string; entityName?: string; entityTypeCode?: number; }; /** * Access page context to return form type. * @deprecated Use XRM members directly. */ export declare function getFormType(xrm: XRM): XrmEnum.FormType; /** If create form, checks formtype and whether there is an id. */ export declare function isCreateForm(xrm: XRM): boolean; /** * Load scripts programmatically. The script is evaluated once loaded by the browser/host. */ export declare function loadScripts(scripts: Array, callback: () => void, targetDoc?: Document): void;