There are a few suggested rules when utilizing jscripts in a CRM application –
- Utilize a standard prefix for created jscript files (i.e. abc_).
- Utilize a consistent naming schema for created jscript files. This provides easier file selection when adding to events and provides cleaner support in a multi-resource environment. (i.e. abc_/functions/forms.js, abc_/functions/entity/account.js, etc).
- Utilize a standard prefix for created jscript files. This provides quick identification of your custom jscript files. (i.e. abc_).
- Do not change jscript files provided by a vendor, especially if they were implemented with a solution. If changes to a function in one of these is required, create a new jscript file and put the replacement function(s) in the new file. Name the new file with a schema that shows a reference to the vendor file. If the vendor provides vdr_crazystuff, create abc_/vdr_crazystuff. Change the event to use the function(s) in the new script.
- Name the functions in the jscript files with a name descriptive of the event and purpose. (i.e. Account_OnLoad(), Contact_OnSave(); ContactCity_OnChange()).
- If there are functions that are not specific to an entity, such as a function to format telephone numbers, use a “global” jscript file to house those funtions. (i.e. put FormatPhone() in abc_/functions/forms.js).
Now, if your CRM application is like most implementations, many functions get incorporated into the OnLoad, OnSave, and OnChange events in multiple forms in multiple entities. Over time, it becomes extremely challenging to know what jscript files and functions are utilized on what form and on what fields. It’s a few steps, but here’s a way to pull that documentation out of your CRM –
1. Make sure all customizations are published.
2. Create a new solution.
3. Select all existing entities into the solution. When prompted, select the “No, do not include required components.” option.
4. Save and export the solution.
5. Ignore the “The following components are missing from your solution.” prompt.
6. Do not select any of the Advanced Settings to be exported.
7. Select the Unmanaged option.
8. Save or move the exported solution zip file to a location that can be accessed by Excel.
9. Extract the files from the solution zip file.
10. Open the customizations.xml file with Excel. When prompted, select “As an XML table”. When prompted with “The specified XML source does not refer to a schema.”, click <OK>. This may take a bit to load.
11. Save as Excel workbook.
12. Sort on the “functionName110” column (depending on your CRM version, it should be somewhere around “JB”).
13. Remove all rows without a value in the “functionName110” column.
14. Change column headings, arrange columns, and sort as desired.
What do you think? Easy enough? Let us know your thoughts below in the comments.