Monday, July 22, 2013

CRM 2011 - Work around for JavaScript Function setFocus()

Recently faced an issue with the setFocus() function in CRM 2011 application. We were doing a validation in a field on change event and if the validation went wrong then we were supposed to show a informative message to the user and then set the focus to the same field.

We have tried below code to set the focus but failed.

Xrm.Page.getControl("fieldName").setFocus(true);
event.returnValue = false;
return;

Later when checked on the web got a blog which was talking about passing the context as a parameter and using the same as below

Xrm.Page.getControl(context.getEventSource().getName()).SetFocus(true);

Unfortunately the same didn't worked for me. I am still not sure what I did wrong in the above approach. You can check the comment section here for this approach. 

Then in another blog we got another method which was achieving my requirement through an illusion of setting focus on my field after setting the focus to another field. So the code would look like this.

Xrm.Page.getControl("another_field").setFocus(true);
Xrm.Page.getControl("actual_field_to_focus").setFocus(true);
event.returnValue = false;
return;

This worked for me anyway. For your reference on the actual blog please check here.

Friday, July 12, 2013

CRM 2011 - Debugging Plugins using Visual Studio

When working on CRM 2011 plugins we might have felt like it could have been easy if we could debug the plugins using Visual Studio. This thought will be more when we have to register the plugin in a different server which might be remote or may be don't have a visual studio version installed.
 
We have a solution for this kind of small problems. Follow the steps below and we can debug our plugins using visual studio.
  1. For registering the plugins we will be using plugin registration tool from CRM SDK. If you are not aware of how to register the same please check this link.
  2. Connect to your server and then the organization.
  3. Register our plugin to be debugged. Make sure a copy of the debug compiled plug in assembly on the computer where we are running the tool.
  4. In the tool's main window, select Install Profiler.
  5. Select the plugin step to be debugged and click on the Profile button to enable profiling. 
  6. Perform the operation in CRM that causes the plugin to execute.
  7. While executing the plugin will throw an exception and the Business Process Error dialog will be displayed.
  8. Download the log file and save this file.
  9. Click Stop Profiling.
  10. In the plugin registration tool click on the Debug button.
  11. In the dialog opened we have to refer two files, one is the location of error file which was downloaded and saved, second is the location of the plugin assembly.
  12. If the server where the tool is running has VS then launch the same and attach the plug in registration tool process for debugging.
  13. Set a break point in the code.
  14. Click Start Plug in Execution  in the debug existing plugin dialog box.
  15. Now you can see the debugger stops in the break point and all is yours.
If the server don't have take the VS instance in the server copy the error details file downloaded in step 8 to the development environment and continue the same process in development environment.
Hope this would help you. Happy debugging !!! :)
 
For Microsoft documentation of the same please refer here.

Wednesday, July 10, 2013

CRM 2011 - Implementing a new Language Pack in CRM 2011

CRM 2011 is give us an option to set the default language. By default it will be English.
 
When a new organization is getting created, we have set the base language for the organization which cannot be changed later.
 
Once the organization is created still we can change the UI Language and Help Language. This can be done using the following steps,
  1. Download the language pack for the respective language from the MSDN site. It can be downloaded here. Select the language you need and click on the download button.
  2. Once the file is downloaded extract the same by double clicking into a single folder.
  3. Now click on the executable extracted and run the same. The new language pack will be installed to the Dynamics CRM folder --> Language packs folder. If we navigates to the same folder we can see that the a new language pack is available there.
  4. Now log in to CRM application and navigate to the Settings --> Administration --> Languages.
  5. Here we will get all the list of language packs installed. Check the respective language and click on the apply button. This will enable the language for the application and the same can be used for our customization. Also note that if we want to disable a particular language come to this same place and uncheck the respective language and click on the Apply button.
  6. Now the language is enabled for the organization and the same is available for us to use in our customization activity. For that click on the "File" tab on our left hand top corner of the screen neat to the Home.
  7. Select the "Options" from the list.
  8. Navigate to the "Languages" tab which comes last in the pop up window.
  9. Select the UI Language and Help Language to the respective one which we need to change. Click on "OK". Its not mandatory to change both the UI and Help languages. Its up to us to customize according to our needs.
Point to be noted here is if the language is different from base language customization options will be disabled, as the same can be done only in the base language.
 
If you need to have some screen shots for the above steps please use the blog in the dynamics community

Configuration for CRM Plugins

CRM plugins are always great feature where we can automate many functionality which we cannot automate from user interface. But almost eve...