CRM 2011 Ajax Loading Message Screen with JQuery

When you use ajax request in CRM2011 (for example, the OData call), the user is not notified when this process happens in the background. Although this call is relatively fast, sometimes you can't predict the performance of it and you want some kind of notification that lets the user know what's happening.

Fortunately with the power of JQuery you can easily make this happen. In my case, I have a custom 'Create Opportunity' button on my custom entity form that gets the data from that entity (and related entity) and create opportunity with those data.

When creating the opportunity using the OData way, I will show the loading message popup with the animated OOTB CRM progress gif image.

To make this happen, it's simple. Just put this function into your onLoad form:

You notice the center() method above. This is an add-on to the jQuery method that you can safely put on your jQuery file:

That's it. Now whenever there is an Ajax call on the form, you will get this message shown up.

Hope this helps,

CRM 2011 JQuery OData REST Endpoints Create Record

In CRM 2011, we can create record easily using JQuery and OData. This will get triggered asynchronously using the ajax functionality.

Create Record function from the SDK:

To create new record, you just need to instantiate your object and call the function. The tricky part is when you want to assign Lookup field or OptionSetValue. You can get more info on this from the SDK itself. Here is an example:

CRM 2011 Javascript Fetch XML synchronous or asynchronous call

Using helper function to execute FetchXML request is great.

The code below is retrieved from this blog, and all I had to do is to add extra logic when parsing the XML result because I want to grab the attributes from the related entity as well.

Modified FetchUtil.js:

To use it you just need to do it like this (synchronous)

If it's asynchronous the last bit will be:

The parsed result object can be queried like this:

Hope this helps,

CRM 2011 Import Custom Workflow Error - Assembly must be registered in isolation

This error does not tell much, but I fixed it by adding myself as a Deployment Administrator.

Hope this helps,

CRM 2011 Partial Refresh with jQuery

This post is a little update on my previous post regarding the Form Refresh after Sub-grid changes.

I find the previous solution annoying in the way that when the user click 'Save' or 'Save and New' , the parent form that got refreshed would get the focus. Also, if the sub-grid had paging on it, the form would get refreshed when you move to the next page - thus you will always get the first page of the sub-grid.

In order to avoid this I found a way to do a partial form element refresh using jQuery load function. The only tricky part is that you have to move your subgrid out of the tab that you want to do partial refresh on. (i.e. partial refresh does not work on sub-grid element).

In my case, my fields that I want to update is on General Tab:

hope this helps,

CRM 2011 Custom Workflow Activity - Send Email to Managers

In CRM 2011 (not online), you can create custom workflow activity for things that are not achievable using the OOTB workflow.

In my scenario, I want to send Overdue Case Reminder to group of users (in this case - managers) when a case has reached the Follow Up By date.
If you look at the SystemUser, it has a manager field by default. However, I need to be able to send the email to multiple managers.

My idea is that we create a separate Security Role (e.g. Managers) and put all managers in that role. Then we create a custom workflow activity to get all the users in that role and construct an email to notify them when the case is overdue.

Note: for the CaseLink input, I'm using the CRM 2011 Workflow Utilities to generate the Case Link and put it into the Email Description field.

Hope this helps,

CRM 2011 Get OptionSetValue Label Text

In CRM 2011, when you try to get the value of an OptionSet, you will always get an Integer value instead of the label value.

I found out that you have to use RetrieveAttributeRequest and get the OptionMetadata in order to get the label text of a given value. This is intended so that it supports multiple languages.

Therefore I created a service extension method in order to get the label from the OptionSet:

To use this you just need to pass in the Entity, the OptionSet attribute you're looking for, and the Option Value you want to get the label from:

Example (early bound):

Hope this helps,