Archive
New JScript syntaxes – CRM 2013
With the advent of CRM 2013, below are the new set of client API methods
Context
- Xrm.Page.context.getUserName() – Returns username of the currently logon user
- Xrm.Page.context.getClient() – Returns the client (i.e., Returns “Outlook”, “Web”, or “Mobile”)
- Xrm.Page.context.client.getClientState() – Returns whether user is working online or offline.
Note – Xrm.Page.context.isOutlookOnline and isOutlookClient methods are deprecated
Data
- Xrm.Page.data.refresh() – Asynchronously refresh data on form without reloading the page
- Xrm.Page.data.Save().then(successCallback, errorCallback) – Allows you to save the record asynchronously with the option to set callback functions to be executed after the save operation is completed.
- Xrm.Page.data.getIsValid() – Validates the form and returns a Boolean.
- Xrm.Page.data.setFormDirty() – Allows to set IsDirty options on the form to (true/false).
Entity
- Xrm.Page.data.entity.getPrimaryAttributeValue() – Returns a string value of the primary attribute for the entity.
Xrm.Utility
- Xrm.Utility.openWebResourceDialog(webResourceName,webResourceData,width,height) – Displays html web resource as dialogs window.
- Xrm.Utility.alertDialog(message,onCloseCallback) – Displays alert box with a callback function.
- Xrm.Utility.confirmDialog(message,yesCloseCallback,noCloseCallback) – Displays confirm dialog with different callbacks depending on Yes/No button clicks.
Set Notifications
- Check this link for syntaxes
Number Fields
- Xrm.Page.ui.controls.get(controlName).setPrecision(2) – Overrides field’s precision
Date Fields
- Xrm.Page.ui.controls.get(controlName).setShowTime(true) – Controls whether to show the time for a date field.
- Xrm.Page.ui.controls.get(controlName).setIsAllDay() – Allows to set the date control to all day date time.
Look up Fields
- Xrm.Page.ui.controls.get(controlName).addCustomFilter(filter,entityLogicaName)
- Applies a custom filter to the lookup view
- entityType is optional and if it is not passed it will default to all entity views
- Xrm.Page.ui.controls.get(controlName).addPreSearch(handler) – Allows to add additional logic that will occur just before the search dialog box
- Xrm.Page.ui.controls.get(controlName).removePreSearch(handler) – Removes event handler functions that previously been set in addPreSearch event.
🙂
Identify “Auto Save” in JScript onload & onsave events – CRM 2013
CRM 2013 has got a new ‘Auto Save” feature which periodically saves the form after new data entered.
Problem with frequent auto save
- The problem with this design is whenever auto-save fires, it causes unwanted execution of the registered onload & onsave events.
To identify ‘Auto Save’ event in ‘onload & onsave’ below is useful approach
On Save
- Check the ‘Save Mode’ of ‘Event Args’, If Save Mode is ‘70’ then save event is caused by ‘Auto Save’
- Make sure to check ‘Pass execution context as first parameter’ while registering ‘onsave’ event
function onsave(eventArgs) {
var saveMode = eventArgs.getEventArgs().getSaveMode();
// 70 – AutoSave
if (saveMode == 70) {
alert(“Save caused by AutoSave”);
// By setting Form dirty, we will make sure the traditional save event executes when you click on ‘Save’ button
Xrm.Page.data.setFormDirty(true);
}
else {
alert(“Traditional Save event”);
}
}
Note –
- Since the ‘AutoSave’ periodically saves the form data, you might not get traditional ‘onsave’ event fired.
- If you want your logic to be executed in traditional ‘onsave’ event, set form dirty to ‘true’ in ‘AutoSave’ save mode.
On Load
‘onload’ event caused by ‘AutoSave’ does not clears the global variables. So use below steps to check ‘AutoSave’ event on ‘onload’
- Declare and set a global variable
- Check the variable on onload event
var formLoaded = false;
function onload() {
if (!formLoaded) {
alert(“Traditional form load happend !!!”);
}
formLoaded = true;
}
- Above function the ‘If’ block executes only first time when you open the form
🙂
Field’s tooltip in CRM 2013
- In CRM 2011, when you hover mouse pointer on a field you get field’s ‘Display Name’ as Tooltip.
- In CRM 2013, there is a slight design change. Whatever you specify in field’s ‘Description’ appear as Tooltip.
🙂
Role based Dashboards – CRM 2013
With the release of CRM 2011, we got System dashboards/charts and Personal dashboards/charts feature.
Dashboards/charts visibility
- System charts are like System views, only Users with System Administrator or System Customizer can create and view-able by all users.
- Personal charts are like Personal views, only visible to User who created them (i.e., Unless the created user shares the personal Dashboard/chart, nobody else can see it, not even a system administrator)
Restrict User to access Dashboards/Charts
- To restrict users to access System dashboards/Charts
- Open security role –> Customization tab, set ‘System Chart/System Form’ access level to ‘none’
- To restrict users to access Personal dashboards/Charts
- Open security role –> Core Records tab, set ‘User Chart/User Dashboard’ access level to ‘none’
By removing privileges to User, he can’t access any of the Dashboards or Charts in the system.
What if you want to restrict a particular System Dashboard or Chart to all ‘Sales Person’ security role Users but not others? You cannot configure OOB this in CRM 2011 (However you can do this by Plug-ins).
With CRM 2013, we got a new feature Role based dashboards similar to Role based forms.
Role based Dashboards in CRM 2013
- With CRM 2013, we can manage permissions for Dashboards and control which user can see each dashboards based on security roles.
- To configure the dashboards based on security roles.
- Open the Solution –> Dashboards, choose single dashboard and click ‘Enable Security Roles‘ button
- Select the “Display only to these select security roles” and select the security roles which are allowed to view this dashboard.
- Publish the customization’s.
🙂
Notifications using script – CRM 2013
CRM 2013 has a new feature to display notifications (i.e., Errors,Warnings and Information’s) like a banner message using JavaScript.
We can create both Form level notifications as well as Field notifications.
- Form notifications
- This method display notifications on the top of the record form.
Syntax – Xrm.Page.ui.setFormNotification(<Notification message>,’ ERROR\WARNING\INFORMATION’);
- Field notifications
Syntax – Xrm.Page.getControl(Field).setNotification(<Notification message>);
Observations
- The Save action happens even if you have form level error notifications
- The order of notifications are 1) Information notifications 2) Error notifications and 3) Warning notifications
- The banner only show 3 rows of notification, the user has to scroll down to see the other
- Use
Xrm.Page.ui.clearFormNotification()
to clear the banner notifications
Refer this link for more details
🙂
Legacy Feature Check Tool – CRM
The next major release of CRM (CRM 2013) is slated to release and will be dropping support for some of the legacy features.
The following legacy components that will not be supported in the next release:
- The 2007 web service endpoint from HTML\JavaScript web resources.
- Plug-ins and custom workflow activities built using the Microsoft Dynamics CRM 4.0 SDK.
- ASPX web pages in the ISV folder.
- The 2007 endpoint from external applications using IIS logs.
Legacy Feature Check Tool
- The “Legacy Feature Check Tool” tool scans the deployment (plug-ins, web resources, IIS logs, and more) and detects the legacy components.
- The tool is safe to run on production deployments and does not update or modify any data or configurations in the deployment
How to run the tool
- Open the CRM web server
- Copy the “LegacyFeatureCheck.zip” folder and extract
- Open the command prompt and point to the “LegacyFeatureCheck” folder
- Run the tool with the /? command-line argument to get the usage instructions
- To inspect one of my organization named “Venilla” for legacy features, run following command
Microsoft.Crm.LegacyFeatureCheck.exe /org:vanilla /out:log.xml
- It writes the log into ‘log.xml’, on the “LegacyFeatureCheck” directory
- The XML will be in below format with issue will be given in <VerificationResult> node
<DeploymentVerificationResults>
<Result>
<OrganizationName>***Deployment***</OrganizationName>
<OrganizationId>00000000-0000-0000-0000-000000000000</OrganizationId>
<Issues>0</Issues>
<Results />
</Result>
<Result>
<OrganizationName>Venilla</OrganizationName>
<OrganizationUniqueName>Venilla</OrganizationUniqueName>
<OrganizationId>f50b3196-b029-e311-bb69-00155db03129</OrganizationId>
<Issues>1</Issues>
<Results>
<VerificationResult>
<Severity>Warning</Severity>
<Component>PluginAssembly</Component>
<ComponentId>b7bed020-bed1-e111-83d9-0019b9f8f548</ComponentId>
<Message>
Assembly “Venilla.Crm.Workflow” with version ‘1.0.0.0’
references the CRM 4.0 SDK.
</Message>
</VerificationResult>
</Results>
</Result>
</DeploymentVerificationResults>
🙂
CRM 2013 – Release Preview Guide
Next major version of CRM release, CRM 2013 is due to release in the fall of 2013.
The CRM 2013 “Release Preview Guide” highlighting some of the key investment areas is available.