Search This Blog

Sunday, June 7, 2015

JavaScript references in Microsoft Dynamics CRM 2013-CRM 2015

If you have any doubt in the post please post comments. I will try to solve your problem.

The JavaScript object model is the JavaScript API that CRM provides to enable you to customize various behaviors based on events and to access CRM data that is present on a form.CRM 2013 fully supports the JavaScript object model from the previous version; however, it does not support the JavaScript object model from Microsoft Dynamics CRM 4.0.

Check out following reference documentation for client-side events and object models that can be used with JavaScript libraries. * marked is new in CRM 2013.
Xrm.Utility: Xrm.Utility object provides a container for useful functions not directly related to the current page. The following table lists the functions of Xrm.Utility.
Xrm.Utility
alertDialogDisplays   a dialog box with a message.
confirmDialogDisplays   a confirmation dialog box that contains a message as well as OK and Cancel   buttons.
isActivityTypeDetermine   if an entity is an activity entity.
openEntityFormOpens   an entity form.
openWebResourceOpens   an HTML web resource.
Xrm.Page.data: Xrm.Page.data provides an entity object that provides collections and methods to manage data within the entity form. The following tables lists the functions ofXrm.Page.data and Xrm.Page.data.entity
Xrm.Page.data
getIsValid*Do a validation check for the data in   the form.
refresh*Asynchronously refresh all the data of the form without reloading the page.
save*Saves the record asynchronously with the option to set callback functions.
Xrm.Page.data.entity
addOnSaveAdds a function to be called when the record is saved.
getDataXmlReturns a string representing the xml that will be sent to the server when the record is saved.
getEntityNameReturns a string representing the  logical name of the entity for the record.
getIdReturns a string representing the GUID   id value for the record.
getIsDirtyReturns a Boolean value that indicates if any fields in the form have been modified.
getPrimaryAttributeValue*Gets a string for the value of the primary attribute of the entity.
removeOnSaveRemoves a function to be called when the record is saved.
saveSaves the record with the options to close or new.
Xrm.Page.context: Xrm.Page.context provides methods to retrieve information specific to an organization, a user, or parameters that were passed to the form in a query string. The following table lists the functions of Xrm.Page.context.
 Xrm.Page.context
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.
getClientUrlReturns the base URL that was used to access the application.
getCurrentThemeReturns a string representing the current Microsoft Office Outlook theme chosen by the user.
getOrgLcidReturns the LCID value that represents   the base language for the organization.
getOrgUniqueNameReturns the unique text value of the   organization’s name.
getQueryStringParametersReturns a dictionary object of key   value pairs that represent the query string arguments that were passed to the   page.
getUserIdReturns the GUID of the SystemUser.Id value for the current user.
getUserLcidReturns the LCID value that represents the provisioned language that the user selected as their preferred language.
getUserName*Returns the name of the current user.
getUserRolesReturns an array of strings that represent the GUID values of each of the security roles that the user is  associated with.
isOutlookClient(Deprecated) Returns a Boolean value indicating if the user is using Microsoft Dynamics CRM for Outlook.
isOutlookOnline(Deprecated) Returns a Boolean value that indicates whether   the user is connected to the CRM server.
prependOrgNamePrepends the organization name to the   specified path.
Xrm.Page.ui:  Xrm.Page.ui provides collections and methods to manage the user interface of the form. The following table lists the functions of Xrm.Page.ui
Xrm.Page.ui
clearFormNotification*Remove form level notifications.
closeMethod to close the form.
formSelector.getCurrentItemMethod to return a reference to the   form currently being shown.
formSelector.itemsA collection of all the form items accessible to the current user.
getViewPortHeightMethod to get the height of the viewport in pixels.
getViewPortWidthMethod to get the width of the viewport   in pixels.
getCurrentControlGet the control object that currently has focus.
getFormTypeGet the form context for the record.
navigation.itemsA collection of all the navigation items on the page.
setFormNotification*Display form level notifications.
refreshRibbonRe-evaluate the ribbon data that controls what is displayed in it.
 Collections
Xrm.Page.data.entity.attributesAll attributes on the page.
Xrm.Page.ui.controlsAll controls on the page.
Xrm.Page.ui.formSelector.itemsAll the forms available to the user.
Xrm.Page.ui.navigation.itemsAll the items in the form navigation   area.
Xrm.Page.ui.tabsAll the tabs on the page.
Xrm.Page Attribute.controlsAll the controls for the attribute.
Xrm.Page.ui Section.controlsAll the controls in the section.
Xrm.Page.ui Tab.sectionsAll the sections in the tab.
 Collections Methods
forEachApply an action in a delegate function to each object in the collection.
getGet one or more object from the collection depending on the arguments passed.
getLengthGet the number of items in the collection.
Attributes: Attributes store the data available in the record. Attributes are available from theXrm.Page.data.entity.attributes collection. To access an attribute you can use theXrm.Page.data.entity.attributes.get method or the shortcut version Xrm.Page.getAttribute. Following table shows how you can query attribute properties to understand what kind of attribute it is or change the behavior of the attribute.
 Xrm.Page.getAttribute(“…”)
getAttributeTypeGet the type of attribute.
getFormatGet the attribute format.
getIsDirtyDetermine whether the value of an   attribute has changed since it was last saved.
getIsPartyListDetermine whether a lookup attribute   represents a partylist lookup.
getMaxLengthGet the maximum length of string which   an attribute that stores string data can have.
getNameGet the name of the attribute.
getParentGet a reference to the Xrm.Page.data.entity object that is the parent to all attributes.
getRequiredLevelReturns a string value indicating   whether a value for the attribute is required or recommended.
getSubmitModeSets whether data from the attribute   will be submitted when the record is saved. always / never / dirty
getUserPrivilegeDetermine what privileges a user has   for fields using Field Level Security.
getValue / setValueGets or Sets the data value for an   attribute.
setRequiredLevelSets whether data is required or   recommended for the attribute before the record can be saved. none / required  / recommended
setSubmitModeReturns a string indicating when data   from the attribute will be submitted when the record is saved.
Number Attribute Methods
getMax / getMinReturns a number indicating the maximum   or minimum allowed value for an attribute.
getPrecisionReturns the number of digits allowed to   the right of the decimal point.
setPrecision*Override the precision set for a number attribute.
DateTime Attribute Methods
setIsAllDay*Specify whether a date control should  set a value including the entire day.
setShowTime*Specify whether a date control should  show the time portion of the date.
Controls: Controls represent the user interface elements in the form. Each attribute in the form will have at least one control associated with it. Not every control is associated with an attribute. IFRAME, web resource, and subgrids are controls that do not have attributes. Controls are available from the Xrm.Page.ui.controls collection. To access a control you can use the Xrm.Page.ui.controls.get method or the shortcut version Xrm.Page.getControl. The following table lists the functions of Controls.
Xrm.Page.getControl(“…”)  
clearNotification*Remove a message already displayed for   a control.
getAttributeGet the attribute that the control is   bound to.
getControlTypeGet information about the type of   control.
getDisabled / setDisabledGet or Set whether the control is   disabled.
getLabel / setLabelGet or Set the label for the control.
getNameGet the name of the control.
getParentGet the section object that the control   is in.
getVisible / setVisibleGet or Set a value that indicates   whether the control is currently visible.
setFocusSets the focus on the control.
setNotification*Display a message near the control to   indicate that data is not valid.
 Lookup Controls: The following table lists the functions of Lookup Control.
addCustomFilter*Use fetchXml to add additional filters   to the results displayed in the lookup. Each filter will be combined with an   ‘AND’ condition.
addCustomViewAdds a new view for the lookup dialog   box.
addPreSearch*Use this method to apply changes to   lookups based on values current just as the user is about to view results for   the lookup.
getDefaultView / setDefaultViewGet or Set Id value of the default   lookup dialog view.
removePreSearch*Use this method to remove event handler
OptionSet: The following table lists the functions of OptionSet Control.
getInitialValueReturns a value that represents the   value set for an optionset or boolean when the form opened.
getOption[s]Returns an option object with the value   matching the argument passed to the method.
getSelectedOptionReturns the option object that is selected.
getTextReturns a string value of the text for   the currently selected option for an optionset attribute.
adoption / removeOptionAdds or remove an option to an option   set control.
clearOptionsClears all options from an Option Set   control.
IFRAME and Web Resource Controls:  An IFRAME control allows you to include a page within a form by providing a URL. An HTML web resource added to a form is presented using an IFRAME element. Silverlight and image web resources are embedded directly within the page. The following table lists the functions of IFrame or Web Resource controls.
getData / setDataGet or Set the value of the data query   string parameter passed to a Silverlight web resource.
getInitialUrlReturns the default URL that an I-frame   control is configured to display. This method is not available for web   resources.
getObjectReturns the object in the form that   represents an I-frame or web resource.
getSrc / setSrcGet or Set the current URL being   displayed in an IFrame or web resource.
Sub-Grid Control: Sub-Grid control has refresh method. We can use this method to refresh data displayed in a Sub-Grid.
refreshRefreshes the data displayed in a Sub-Grid.
OnChange Event: There are three methods you can use to work with the OnChange event for an attribute.
addOnChange / removeOnChangeSets or remove a function to be called   when the attribute value is changed.
fireOnChangeCauses the OnChange event

1 comment:

Note: Only a member of this blog may post a comment.