8473.CRM 2015 Cheat Sheet Client API

CRM 2015 Client API
Xrm.Utility
Xrm.Page.data
Parameters
Description
alertDialog
message,onCloseCallback?
confirmDialog
message,yesCloseCallback?,noCloseCallback?
Displays a dialog box containing an applicationdefined message.
Displays a confirmation dialog box that contains an
optional message as well as OK and Cancel buttons.
isActivityType
entityName
Determine if an entity is an activity entity.
openEntityForm
name,id?,parameters?,windowOptions?
Opens an entity form for a new or existing entity
record using the options you set as parameters.
windowOptions is only available 2015 Online
Update 1+
openQuickCreate callback?,entityLogicalName,createFromEntity?, Opens a new quick create form. 2015 Online Update
parameters?
1+
openWebResourc webResourceName,webResourceData?,width?, Opens an HTML web resource. Does not work on
e
height?
Tablets
Xrm.Page
Xrm.Page.data.entity
Parameters
Description
refresh
save?
save
saveOptions?
Asynchronously refreshes and optionally saves all
the data of the form without reloading the page.
Saves the record asynchronously. saveOptions is
only available 2015 Online Update 1+
then
successCallback?, errorCallback?
Xrm.Page.data.entity attribute/Xrm.Page.getAttribute
Parameters
getControl
Description
controls
A collection of all the controls representing the attribute.
getAttributeType
Returns a string value that represents the type of attribute.
getFormat
Returns a string value of formatting options for the
attribute.
Returns a bool that indicates if there are unsaved changes.
getIsDirty
getAttribute
Method is appended to above calls.
Parameters Description
attributes
A collection of all the entities attributes/fields
getDataXml
getEntityName
Returns a string representing the XML that will be sent to the
server when the record is saved. Does not work on Tablets
Returns the logical name of the entity for the record
getId
Returns the id value for the record.
getIsDirty
Returns a bool that indicates if any fields have been modified.
addOnSave
Adds a function to be called when the record is saved.
removeOnSave
Removes a function to be called when the record is saved.
getPrimaryAttributeValue
Gets a string for the value of the primary attribute of the
entity
Saves the record synchronously with the option to close or
open a new form after completed.
save
action?
Xrm.Page.data.process
Parameters
Description
getMaxLength
schemaName
Retrieves an attribute from the
Xrm.Page.data.entity.attributes collection
getName
Returns a number indicating the max length of a string or
memo.
Returns the logical name of the attribute.
Retrieves a control from the Xrm.Page.ui.controls collection.
getParent
Returns the Xrm.Page.data.entity object.
setActiveProcess
getUserPrivilege
Returns an object with 3 bools indicating privileges of
create, read, and update.
Sets a function to be called when the value is changed.
getActiveStage
Id
Xrm.Page.context
Parameters Description
client.getClient
Returns a value to indicate which client the script is executing in.
client.getClientState
Returns a value to indicate the state of the client.
getClientUrl
Returns the base URL what was used to access the application.
getCurrentTheme
Returns a string representing the current Microsoft Office Outlook theme
chosen by the user.
Returns whether Autosave is enabled for the organization.
getIsAutoSaveEnabled
getOrgLcid
getOrgUniqueName
getQueryStringParameters
getTimeZoneOffsetMinutes
getUserId
getUserLcid
getUserRoles
removeOnChange
removeOnSave
fireOnChange
Returns a dictionary object of key value pairs that represents the query
string arguments that were passed to the page.
Returns the difference between the local time and Coordinated Universal
Time (UTC).
Returns the GUID of the SystemUser.Id value for the current user.
OptionSet/Boolean
setRequiredLevel
prependOrgName
sPath
Returns and array of strings that represent the GUID values of each of the
security roles that the user is associated with or any teams the user is
associated with.
Prepends the organization name to the specified path.
Collections
getInitialValue
getRequiredLevel
getOption
setSubmitMode
getOptions
getSelectedOption
getSubmitMode
getText
setValue
Number
stageId,
callbackFunction?
getEnabledProcesses
callbackFunction
moveNext
callbackFunction?
Set a completed stage for the current entity as the
active stage.
Returns a collection of stages for the current, branched
BPF.
Asynchronously returns enabled BPFs. Callback must
accept object.
Progresses to the next stage.
movePrevious
callbackFunction?
Moves to the previous stage.
Causes the OnChange event to occur.
requirementLevel Sets whether data is “required”, “recommended”, or
“none”.
Returns the value set when the form opened.
Returns a string indicating the requirement level for an
value
Returns
an option object with the value matching the
attribute.
argument passed.
submitMode
Sets when the data will be submitted
Returns
an array of option objects.
(“always”,”never”,”dirty”).
Returns the
option
object for
thethe
selected
option.
a string
indicating
when
data will
be
submitted.
Returns the text value of the currently selected option.
value
Sets the data value for an attribute.
addOnStageChange
Sets a function to be called when stage is changed.
removeOnStageChange
Removes a function from the OnStageChange event.
addOnStageSelected
Sets a function to be called when stage is selected.
removeOnStageSelecte
d
Process
Removes a function from the OnStageSelected event.
getId
Returns the ID of the process.
getName
Returns the name of the process.
getStages
Returns a collection of Stages.
isRendered
Returns true if the process is rendered, false if not.
Stage
getMin
Returns a number indicating the minimum allowed value.
getEntityname
Returns an object with a getValue method to return the
integer value of the category
Returns the logical of the associated entity.
getPrecision
Returns the number of digits to the right of the decimal
point.
getId
Returns the ID of the stage.
getName
Returns the name of the stage.
getStatus
Returns the status of the stage.
getSteps
Returns a collection of steps in the stage.
forEach
delegate function
Apply an action in a delegate function to each object in the
collection.
getIsPartyList
get
value
Get one or more objects from the collection.
Parameters
Returns a Stage object representing the active stage.
getCategory
Lookup
Execution Context
Removes a function from the OnChange event.
Returns a bool that indicates if the lookup is a partylist.
Steps
getAttribute
GetGlobalContext
getName
Returns the logical name of the attribute associated
with the step.
Returns the name of the step.
isRequired
Returns whether the step is required in the BPF
Description
getContext
Returns client-side context object.
getDepth
Returns a value indicating when the handler is executed.
getEventArgs
Returns an object with methods to manage the Save event.
getEventSource
Returns a reference to the object that the event occurred on.
getSharedVariable
Returns a variable set using setSharedVariable.
setSharedVariable
Sets the value of a variable to be used by the next handler.
Returns a Process object representing the active
process.
Set a process as the active process.
Retrieves the data value for an attribute.
Returns a number indicating the max allowed value.
Description
Gets the number of items in the collection.
setActiveStage
processId,
callbackFunction?
Description
getValue
getMax
Parameters
getLength
getActiveProcess
getActivePath
Returns the LCID value that represents the base language for the
organization.
Returns the unique text value of the organization’s name.
Returns the LCID value that represents the Language Pack that the user
selected as their preferred language.
Returns the name of the current user.
getUserName
addOnChange
addOnSave
Parameters
ClientGlobalContext.js.aspx
Xrm.Page.ui tab
Xrm.Page.ui
Parameters
Description
Parameters
close
Method to close the form.
getDisplayState
controls
A collection of all the controls on the page
setDisplayState
formSelector.items
getFormType
A collection of all the form items accessible to the current
user.
Method to return a reference to the form currently being
shown.
Method to get the control object that currently has focus on
the form.
Method to get the form context for the record.
navigation.items
A collection of all the navigation items on the page
formSelector.getCurrentIte
m
getCurrentControl
setFormNotification
message, level, uniqueId Use this method to display form level notification.
clearFormNotification
uniqueId
refreshRibbon
Use this method to remove form level notifications
Xrm.Page.ui.navigation item
Description
Parameters
Description
Returns a value that indicates whether a tab is collapsed or expanded.
getId
Returns the name of the item.
Sets the tab to be “collapsed” or “expanded”.
getLabel
Returns the label for the item.
getName
Returns the name of the tab.
setLabel
getParent
Returns the Xrm.Page.ui object.
setFocus
Sets the focus on the item.
getLabel
Returns the tab label.
getVisible
Returns a value that indicates whether the item is visible.
Sets the label for the tab.
setVisible
setLabel
string
string
sections
A collection of all the sections in the tab.
setFocus
Sets the focus on the tab.
getVisible
Returns a value that indicates whether the tab is visible.
setVisible
bool
Sets a value that indicates whether the tab is visible.
Xrm.Page.ui section
string
Sets the label for the item.
bool
Sets a value that indicates whether the item is visible.
Xrm.Page.ui.formSelector item
Parameters
Description
getId
Returns the ID of the form.
getLabel
Returns the form label.
navigate
Opens the specified form.
tabs
Method to cause the ribbon to re-evaluate data that
controls what is displayed in it.
A collection of all the tabs on the page.
getViewPortHeight
Method to get the height of the viewport in pixels
controls
A collection of controls in the section.
getViewPortWidth
Method to get the width of the viewport in pixels
getName
Returns the name of the setction.
getParent
Returns the tab containing the section
setDisplayState strExpanded
Sets the BPF control to be “collapsed” or “expanded”.
getLabel
Returns the section label.
setVisible
Sets the BPF control to be visible or hidden.
Xrm.Page.ui control/Xrm.Page.getControl
Parameters
getDisabled
setDisabled
bool
Description
Parameters
setLabel
Returns whether the control is disabled.
getVisible
Sets whether the control is disabled.
setVisible
string
Description
Sets the label for the section.
Returns a value that indicates whether the section is visible.
bool
Xrm.Page.ui.process
Parameters
Description
boolVisible
Save event arguments
Parameters
Sets a value that indicates whether the section is visible.
Description
getAttribute
Returns the attribute that the control is bound to.
getSaveMode
Returns a value indicating how the save event was initiated.
getControlType
Returns a value that categorizes controls.
isDefaultPrevented
getName
Returns the name assigned to the control.
SubGrid
getParent
Returns a reference to the section object that contains
the control.
Returns the label for the control.
refresh
Returns a value indicating whether the save event was canceled
because of the preventDefault method.
Cancels the save operation, but all remaining events will be
executed.
GridControl
getLabel
Parameters
Description
Refreshes the data displayed in the subgrid.
2015 Online Update 1+
setLabel
label
Sets the label for the control.
addOnLoad
Used to add event handlers to the OnLoad event.
setNotification
message,uniqueId
Display a message near the control for invalid data.
getContextType
Returns context information about the control.
clearNotification
uniqueId
Remove a message already displayed for a control.
getEntityName
bool
Returns a value that indicates whether a control is
visible.
Sets whether the control is visible.
getVisible
setVisible
setFocus
Sets the focus on the control.
Lookup
filter,entityLogicalName
addCustomView
Adds filter to the results displayed in the lookup.
1 Create (and Quick Create)
2 Save and Close
getGrid
Returns the Grid object available in the control.
2 Update
59 Save and New
getViewSelector
Returns the ViewSelector object available in the control.
3 Read Only
70 AutoSave
removeOnLoad
Removes event handlers from the OnLoad event.
4 Disabled
58 Save as Completed
2015 Online Update 1+
getSelectedRows
Returns a collection of every selected GridRow in the Grid.
getDefaultView
getTotalRecordCount
Returns the total number of records in the Grid.
setDefaultView
viewGuid
Sets the default view for the lookup dialog box.
GridRow
Used to apply changes to lookups based on values when
the user is about to view results.
Removes a function from the PreSearch event.
getData
addOption
option,[index]
number
getShowTime
setShowTime
bool
Returns the logical name for the record in the row.
getEntityReference
Returns a lookup object for the record in the row.
getId
Returns the id for the record in the row.
getPrimaryAttributeValue
Returns the primary attribute value for the record.
WebResource
getData
setData
Returns a reference to the current view.
isVisible
Returns true if view selector is visible, false if not.
viewSelectorItem
string
Sets the value of the data query string parameter.
ViewSelectorItem
2015 Online Update 1+
getEntityReference
string
Returns the object in the form that represents the web
resource.
Sets the URL to be displayed.
Returns the current URL being displayed.
addOnResultOpen
Adds an event handler to the OnResultOpen event.
addOnSelection
Adds an event handler to the OnSelection event.
getSearchQuery
Returns the text used as the search criteria.
getSelectedResult
Returns the currently selected result.
removeOnResultOpen
Removes a function from the OnResultOpen event.
removeOnSelection
Removes a function from the OnSelection event.
IFrame
getInitialUrl
getObject
getSrc
getCurrentView
string
Returns the default URL than an Iframe control is
configured to display.
Returns the object in the form that represents an
IFrame
Sets the URL to be displayed.
Returns the current URL being displayed.
kbsearch
setSearchQuery
Utility
Page
context
data
2015 Online Update 1+
setCurrentView
getSrc
setSrc
ViewSelector
2015 Online Update 1+
Returns the value of the data query string parameter.
getObject
setSrc
Returns the GridEntity for the GridRowData.
getEntityName
Sets whether a date control should show the time
portion.
15 Disqualify
Xrm
2015 Online Update 1+
Clears all options from an option set control.
Get whether a date control shows the time portion.
7 Send
Returns the GridRowData for the GridRow.
GridEntity
DateTime
47 Assign
16 Qualify
Adds an option to an option set control.
Removes an option from an option set control.
6 Reactivate
2015 Online Update 1+
getEntity
clearOptions
removeOption
GridRowData
5 Deactivate
6 Bulk Edit
viewId,entityName,viewDisplayNa Adds a new view for the lookup dialog box.
me,fetchXml,layoutXml,isDefault
Returns the ID value of the default lookup dialog view.
OptionSet
Value Text
Value Text
Returns the logical name of the entity data displayed.
Returns a collection of every GridRow in the Grid.
removePreSearch
.getSaveMode()
1 Save
getRows
addPreSearch
.getFormType()
0 Undefinied
Grid
addCustomFilter
preventDefault
entity
process
attribute
Process
ui
navigation
Sets the current view.
Returns a lookup object for the view.
tab
item
process
2015 Online Update 1+ Requires Parature integration
string
Sets the text used as the search criteria.
Stage
Steps
control
section
formSelector
item