B L O G
CRM 2011 Data Import - Creating web resources
CRM 2011 now allows you to share Javascript by creating what is known as a "Web Resource".
STEP 1
Select Settings => Customiztions => Web Resource => New.
STEP 2
Enter the "Name", "Display Name", select "Script(JScript)" for type and press on the "Text Editor" to begin entering your code
STEP 3
Create a function and write the code. This example contains three functions
1. Function for formatting a phone number
2. Function for formatting a social security number
3. Function that strips non numberic characters
Click here to download the code
This example uses regular expressions to fomat the strings. Press OK when finished
STEP 4
When you are finished the new "Web Resource" will be displayed on the list. Click on the Publish icon.
STEP 5
Select the entity where you want to use the "Web Resource". This examples useas the "Account" entity. Go to Customizations => Customize the System => Entities => Account => Forms => Main
STEP 6
Double click on the field where you want to reference the "Web Resource". This example highlights the "Main Phone" field.
STEP 7
Add the function you want to use in the "Event Handlers" section. In this example we want to use the "formatPhoneNumber" function on the "OnChange" event. Click OK when finished.
Important - Event Handler Properties
1. Make sure the function is "Enabled"
2. You pass the execution context as first parameter
STEP 8
Save and close when finished.
STEP 9
Go back to the list of entities and publish the Accounts entity
STEP 10
Your script is not activated and the next time the system senses a change on "Main Phone" field it will format the field or diaplay and error message. The "Other Phone" and "Fax" fields were modified to use the same formatting function during a change event.
STEP 11
This screens shows how the all three fields have been formated by the same function.