Users are not seeing any error message to alert them that the account name is invalid. Joe was unable to determine the problem at first glance and needs to debug the library. Here are the functions.
Tip! Refer to the MSDN developer network for more details on Internet Explorer’s Developer Tool.
Here’s how Joe resolves the problem:
- Joe navigates to the account form in CRM and presses F12 to open the Developer Tools window.
- He then navigates to the Script tab
3. To select a library to debug, Joe clicks the View Sources button and selects the appropriate library from the list.
This should bring up the appropriate library for inspection. To begin debugging Joe needs to click on the far left of the line he wishes to begin debugging to insert a breakpoint. Placing the cursor on the desired line and pressing F9 will also place a breakpoint. Next he should click the Start Debugging button. A popup may prompt you to reload the form at this point. Select the option to leave the current form and allow the form to reload.
4. Now Joe triggers the function by entering an invalid value in the Name field. Line 13 of the library is the check condition for the value. If the Name field exists on the form and the value is less than 3 characters the message box should show.
Joe enters ‘ab’ into the field and the presses Tab to trigger the function. When the form reaches the breakpoint assigned on line 8 Joe will be able to use the debugger to inspect the logic.
5. Pressing F10 or clicking the Step Over button will move the Joe through the logic
After stepping through the function several times Joe realizes that lines 11 -15 are never getting triggered. The if condition on line 10 makes sure that the accountName field exists on the form. By hovering the mouse over the accountName variable Joe can see that the getAttribute() function is not finding the name field. Upon inspecting the field name specified in getAttribute() he sees that an ‘s’ is included in the name. The correct name of the attribute is ‘name’.
6. After modifying the logic in the library, publishing the change, and reloading the account form the issue is resolved.
Visual Studio can also be used to debug libraries. For instructions on how to do this review the following articles: