Hello JScript friends,
I'm back from vacation and back again to enjoy some interesting jscript stuff with you. Do you like JScript? I do not! However, since Web 2.0 and AJAX, it has become very popular because it makes web applications much more user friendly. And you could use jscript even for extending the client side behaviour of Microsoft Dynamics CRM. That is one more reason to use the good old trial-and-error script language. Especially AJAX techniques will help you to add validation logic on the client side of Microsoft CRM.
In this post I would like to show you how you could use AJAX-techniques together with Microsoft CRM to implement the following functionality:
1. Creating auto suggestion fields for Microsoft CRM 2. Load the data for the auto suggestion list via a web service.
Just take a look at the screenshots and you will understand what I mean. This is just a simple functionality/function but you can use this technique in many other scenarios. E.g. server side validations without a roundtrip or having a central list without using picklists.
1. Creating auto suggestion fields for Microsoft CRM
Lets start: just copy the following function into the onload event of any entity.
Next, we have to call the function for every textfield where we want to add this behavior.
We will call the function "SuggestionTextBox" and passing three parameter:
For demoing purpuses I just created the function 'f', which returns some countries. So copying the above code into the onload event handler of the entity. Thats it, just save your form and publish your changes. Now you can open the form and by typing the first character the auto suggestion box will appear.
2. Load the data for the auto suggestion list via a web service.
Now that we have a great suggestion functionality we can now start to make the list a little bit more dynamic. So instead of fixed function which returns static list of items, we could load them every time by using a web service.
Web Service function, which returns a list of values:
Last step, we will call the web service and init our suggestion text box. Add the following code to your onload event handler:
Thats it. Do you like it? Please let me know if that works fine for you or if you made any improvements. I'd love to hear from you!
Other interesting blogs regarding this topic:
Accessing Web Services From CRM Forms http://blogs.msdn.com/arash/archive/2006/02/01/521565.aspx
Address Validation in Three Easy Steps!http://www.invokesystems.com/cs/blogs/mscrm/archive/2006/06/21/38.aspx
Working with CRM Form Lookup Controls Programmatically http://blogs.msdn.com/arash/archive/2006/03/28/562846.aspx
Finally there: Show and hide fields based on the users role! http://ronaldlemmen.blogspot.com/2006/05/finally-there-show-and-hide-fields.html
Inserting City and State Automatically based upon Zip Codehttp://blogs.msdn.com/midatlanticcrm/archive/2006/06/22/Inserting_City_and_State_Automatically_based_upon_Zip_Code_Microsoft_CRM_3.aspx