In Microsoft Dynamics CRM 4, it is a very tedious task for system customizers to manage and track JavaScript. System Customizers/Developers have to write JavaScript on every event handler on the form. But Microsoft Dynamics CRM 2011 provides JavaScript libraries that can be utilized on events and forms across the solution. Now common JavaScript functions can be written at one centralized JavaScript file and utilized across solution.
Moreover, multiple JavaScript libraries can be created. For example, one common library for general CRM Service calls and one common library for UI manipulation and so on.
Let’s create a very simple JavaScript library and create a function to hide/show a tab/section on the form. JavaScript libraries are added as web resources in solution as shown below:
Now let’s create a JavaScript Common Library by adding a web resource in the solution. Then attach a JavaScript file this web resource.
Now let’s open the file in Text Editor available in web resource to add a function to show/hide a section/tab on form.
Microsoft Dynamics CRM 2011 provides new xrmPage model to access UI and data at client side. Here is a snapshot of the hierarchy.
Now let’s go to the account form in solution and then go to form properties to set JavaScript library and function to execute on form load event handler as shown below:
Now let’s add library from solution library.
Now let’s call the HideShowSection function in JavaScript Library by selecting appropriate JS library and typing the right function. Enable the event handler by setting Enable flag to true. Also pass parameter to function by comma separated list of parameters i.e. 1, false which in turn sets tab 1 to visible false.
You can see that Details tab is now hidden and alert.
No comments:
Post a Comment