Once we have defined the processes we want to capture within our CRM system and we have begun our design and captured a user's usage scenarios, we often find places where custom code can help with automating some user processes to make them more efficient or enforce data validation.
There are many different options to automate business processes within Microsoft Dynamics CRM 4.0. Today we will look at the differences between doing it via JavaScript that calls back into the CRM API’s versus using Plug-ins.
Automating Business Processes: Using JavaScript to Call API's vs. Plug-ins
Data validation and retrieval from other CRM entities or systems are often useful when automating business processes. There are multiple ways you can accomplish these tasks in Microsoft CRM. Two frequently used methods are synchronous plug-ins and form-level JavaScript calling either the CRM API's or integrating with another system.
One benefit to using JavaScript is that since JavaScript is run on the form (client-side), it can react to any OnChange or OnLoad event on the form and provide immediate feedback to users. In other words, users do not have to wait until saving the form for data validation or retrieval to take place. Additionally, client-side JavaScript allows for greater flexibility when communicating messages to the user, as well as with field manipulation. JavaScript's downside is that since it runs client-side, it requires more roundtrips between the server and client. This approach is not an issue if most users have good connections to the server. However, a client-side approach can impact performance in the case of a deployment with users spread across multiple offices or with users having slow server connections. Furthermore, creating an additional client-side connection to the CRM server or other external servers can break functionality when a user is offline or cannot access the external server. Another point to consider is that the use of client-side scripting transfers additional processing load from the server to the client
To contrast, Plug-ins in Microsoft Dynamics CRM 4.0 run server-side and therefore do not offload any processing load to the client. This is usually a non-issue unless your CRM server is underpowered. With server-side processing, the performance impact will be the same for all users no matter where they access CRM from. Another benefit is that the Microsoft CRM Plug-in model has built in ways to handle online and offline processing that are described in the CRM SDK. The downsides of using Plug-ins are that a user must click save to trigger the Plug-in and there are a limited set of responses you can send to the user from within your plug-in.
Both Plug-ins and JavaScript scripting to call API's have their uses. For example, JavaScript is a viable choice and could be the best solution if you are building a solution for a call center where all users have consistently fast connections and immediate data validation response helps their business process. On the other hand, if you have a dispersed workforce with slow or limited connections to CRM server, then the plug-in model might work better for you. One roundtrip on-save that results in an error message might be much quicker than waiting for multiple server roundtrips after each field is filled out.
- Hoss Hostetler