Monday, April 30, 2012

Visually Differentiate Dynamics CRM 2011 Environments (alternate)

I am a big fan of this hack to visually differentiate CRM environments and have been using it religiously in all CRM environments I have worked on.
I have since found an implementation of for CRM 2011 here. Although it served its purpose, I was not quite comfortable with changing the ribbon styles as it could be a annoyance when designing/implementing ribbon icons. So here is my take on it:
There are 2 files that require modification; main.css.aspx and theme.css.aspx (The theme.css.aspx file only needs to be modified if you want this to work with read-only forms). You can find them both under %programfiles%\Microsoft Dynamics CRM\CRMWeb\_common\styles folder.

main.css.aspx

div.ms-crm-TopBarContainerGlobal
{
/* background-repeat: no-repeat;
background-color: #ffffff; */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00ff00', endColorstr='#0100ff',GradientType=1 ); /* IE6-9 */
}

div.ms-crm-TopBarContainerForm
{
/* background-repeat : repeat-x; */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00ff00', endColorstr='#0100ff',GradientType=1 ); /* IE6-9 */
}

themes.css.aspx
div.ms-crm-ToolBar
{
<%--<% = this.GetStyleCss(CrmTheme.Current.Form.ToolBar) %>--%>
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00ff00', endColorstr='#0100ff',GradientType=1 ); /* IE6-9 */
}

The gradients were generated using CSS gradient editor.

IIS Reset for the changes to take effect.


An here is the end result:
image

image

As this is an un-supported change, you would not be able to implement this in a CRM Online environment. Here is an alternate solution that works well with CRM Online.

Saturday, April 28, 2012

Bookmark Organizer 0.1 for Windows Phone 7.5


I saw a tweet a few days back where someone wanted to sync favorites within windows phone. Unfortunately, the current iteration of the OS does not allow developers that level of access to their favorites. I was curious if it was still achievable, at least via un-supported means and this app was the result.

A little research revealed that the phone stores the favorites as url files within the \Windows\Favorites folder and that Internet Explorer treats every file with a “.url” extension as a favorite entry. It was only a matter of reading and manipulating these files.

This initial version allows to do basic CRUD operations on the available bookmarks and also import from a hosted CSV file. The CSV file itself should be a valid 2 columned file containing the Title and Url of the bookmark.
The app is built around the WP7 Root Tools SDK 0.1.6.0 alpha which does most of the heavy lifting.

Pre-requisites:


Installation:

  1. Download and deploy the XAP file using your favorite deployment tool.
  2. Make Bookmarks Organizer a trusted app using WP7 Root Tools

Future version:

  • The ability to do 2 way sync with a cloud service.
  • Improved UI maybe?

Disclaimer:

This app interacts with system files that were not meant to be accessed. I hold no responsibility if your phone gets ‘bricked’, blows up or any other unfortunate mishap by using this application. Please use at your own risk.
Please feel free to email me your comments, feature requests or bugs.

Download:

Thursday, April 19, 2012

Flashing OEM ROM on Samsung Focus

I flashed my Samsung Focus using the Rogers OEM ROM the other day and then followed the update method described here to get back to 7.10.8107.79 within 30 mins.

Why? Because my Samsung Focus is finicky on the best of days. More so when it comes to pushing updates via Zune. It was a nightmare getting Mango on it when it was first release, I kept hitting the dreaded 80180048 error. And my slow as molasses internet connection was not helping; constantly re-downloading 160+ Megs of updates for each failure was painful to say the least. My best guess was something somewhere was timing out. And I was not too keen on going through that whole process again.

Followed everything described on the thread. Although I didn’t install the OEM drivers that were provided, I let Zune pick them out for me and this is what it got me:

This one brings the firmware up to 2124.11.8.1: http://download.windowsupdate.com/msdownload/update/software/dflt/2011/08/404680_i917rrwckh1_prod.pks_c73375d693c8eae569b062eefedea268bbe907d1.cab

And this to 2124.11.9.4: http://download.windowsupdate.com/msdownload/update/software/dflt/2011/10/417964_i917rrwcki4_prod.pks_1636e51c72b74f38ddfdf77ee9bbf5b2efb1d732.cab

The above links were not present on the original thread at the time of writing, I hope it helps someone else out there.

Friday, April 13, 2012

Listing of Form Mode For Organization Users

With rollup update 7, Dynamics CRM introduced Read-Optimized Forms and gave administrators the ability to set the default Form Mode for all users within the organization. It also provides the option to allow users to override this selection as well.

Dynamics CRM Default Viewing Mode
Dynamics CRM Default Individual

If the latter option is enabled, I noticed that CRM does not provide administrators a way to view the user’s selection. This information is not available in any of the out of the box views nor can it be added as the Form Mode selection is stored within the UserSettings entity.
The following FetchXml used within a SSRS report should fill the requirement gap:
<fetch mapping="logical" count="50" version="1.0">
  <entity name="systemuser">
    <attribute name="address1_telephone1" />
    <attribute name="businessunitid" />
    <attribute name="fullname" />
    <attribute name="siteid" />
    <attribute name="title" />
    <filter>
      <condition attribute="isdisabled" operator="eq" value="0" />
    </filter>
    <link-entity alias="settings" name="usersettings" from="systemuserid" to="systemuserid">
      <attribute name="entityformmode" />
    </link-entity>
  </entity>
</fetch>

Read-Optimized Forms Enabled Users 

And best of all, this method is fully supported.

Thursday, April 12, 2012

Calculated Fields In Dynamics CRM Read Optimized Forms

The latest rollup update introduced a new feature called Read Optimized Forms. This enables a read-only version of the entity forms that optimized for users that want to rapidly read data instead of editing them.

One of the pre-requisites in the current implementation is that the form should be devoid of all script customizations. If so, how would you work around a situation where the form requires values to be dynamically calculated.

One of the recommended approaches, as defined in the SDK, is to use a synchronous sandbox plugin running on the Retrieve message of the entity.

The following code snippet demonstrates this:

  1. protected void ExecuteDynamicCalculationPlugin(LocalPluginContext localContext)
  2. {
  3.     if (localContext == null)
  4.         throw new ArgumentNullException("localContext");
  5.  
  6.     //The OutputParameters property bag contains the result of the core operation.
  7.     Entity outEntity = localContext.PluginExecutionContext.OutputParameters["BusinessEntity"] as Entity;
  8.  
  9.     //Ensure values are valid to perform calculation
  10.     if (outEntity.Attributes.Contains("null_hours") &&
  11.         outEntity.Attributes.Contains("null_days"))
  12.     {
  13.         int hours = (int)outEntity.Attributes["null_hours"];
  14.         int days = (int)outEntity.Attributes["null_days"];
  15.  
  16.         outEntity.Attributes["null_hours"] = hours * days;
  17.     }
  18. }

crm2011 post event registration

And the plugin is registered as PostOutsideTransaction on the Retrieve event of the entity with the assembly under Sandbox isolation. This approach would also work on Online solutions as well.

Please beware of long running calculations as they are now being done synchronously as opposed to being done asynchronously through JavaScript.

Sunday, April 08, 2012

Dynamics CRM Security Role with Minimum Permission

When it comes to software solutions, it is always best practice to follow the Principal Least Privilege. This is no different with Dynamics CRM 2011. This post will provide you will basic instructions in creating a security role with the least privileges.

The help page in the Security Role entity under the “Create or edit a security role” topic already provides a pretty good summary of the minimum privileges required:

It's helpful to keep in mind the minimum privileges you need to define for some common tasks. These include:

  • When logging in to Microsoft Dynamics CRM:
    1. To render the home page: prvReadWebResource, prvReadCustomization
    2. To render an entity grid (that is, to view lists of records and other data): Read privilege on the entity, prvReadUserSettings, prvReadQuery
    3. To view single entities in detail: Read privilege on the entity, prvReadSystemForm, prvCreateUserEntityUISettings, prvReadUserEntityUISettings
  • When logging in to Microsoft Dynamics CRM for Outlook:
    1. To render navigation for Microsoft Dynamics CRM and all Microsoft Dynamics CRM buttons: prvReadEntity, prvReadQuery
    2. To render an entity grid: Read privilege on the entity, prvReadCustomization, prvReadWebResource, prvReadUserQuery
    3. To render entities: Read privilege on the entity, prvReadSystemForm, prvCreateUserEntityUISettings, prvReadUserEntityUISettings, prvWriteUserEntityUISettings

So suppose I want a user to have minimum read permission to a Custom Entity and for him to view records that have been assigned to him. I would add the following permission:

Basic Read Permission on your entity (prvRead[entityName])

EntityReadPermission

Access to Viewing the entity grid and entity forms (prvReadQuery, prvReadSystemForm)
As well as the permissions that are added by default (prvReadSdkMessage, prvReadSdkMessageProcessingStepImage, prvReadSdkMessageProcessingStep, prvReadPluginAssembly, prvReadPluginType) These permissions are required for smooth operations of internal operations such as core CRM plugins.

Forms and Views

The UserEntity UI Settings provides access to the functionality to remember the user’s last accessed Form (prvCreateUserEntityUISettings, prvReadUserEntityUISettings)

User UI Settings

Permission to access User Preferences (prvReadUserSettings)

UserSettings

Also keep in mind that when designing security roles, a good understanding of the organization structure and deployed CRM solutions is key to success. As it is possible that there are additional plugins and workflows running in the background that require additional permissions.