locked
Where does one enter the JavaScript code in CRM Dynamics? RRS feed

  • Spørgsmål

  • I've started to play with CRM Dynamics yesterday so this question should be seen as a very basic one. I've been coding for many years but CRM D is news to me.

    Apparently, one is supposed to be able to enter JavaScript code to customize the behavior of the application. I've understood that there's an API for that and that touching DOM directly or playing with jQuery is a no-no.

    Question: Where is the JS-code supposed to be entered? I've gone through all the menus but as far I can see, there's no spot where I could plug-in my custom code.

    E.g.: Where do I get to define a validation for the last name of a contact currently being defined?

    (Please note that I posted the same question on StackOverflow first and got a suggestion to ask here from an associate.)


    • Redigeret af Viltersten 2. september 2012 22:03 Formatting
    2. september 2012 22:00

Svar

  • Hi,

    JavaScript is entered into a web resource and then uploaded to CRM. This can then be referenced from an entity forms Properties.

    Once a web resource has been loaded on the form you can begin adding function calls to the OnLoad event under Properties, and also to field OnChange events.

    When calling the function you simply select the javascript library, enter the function name, and pass any parameters.

    Here is a step by step on adding javascript to a form:
    http://www.magnetism.co.nz/blog/11-01-05/JavaScript_Libraries_on_a_Form_in_Dynamics_CRM_2011.aspx

    Hope that helps!

    -Paul


    3. september 2012 01:16
  • Settings -> Customizations -> Customize the System -> Look for Web Resources in the left navigation

    You can create a JavaScript file defining methods you wish to call from different form/field events. 

    Web Resources for Microsoft Dynamics CRM

    Microsoft Dynamics CRM 2011 Software Development Kit

    In your example your JavaScript file might look like this:

    function ValidateLastname() {
         //Do work
    }
    

    On your contact form, when in customize mode, you can add a reference to your web resource script file by adding it under the form properties.

    Then when you are customizing the form, on the last name field you can edit the field properties and bind the ValidateLastname method to the OnChange event of the field. 

    Make sure and publish both the web resource and the form before testing.


    Jason Lattimer

    3. september 2012 01:26
    Redaktør

Alle besvarelser

  • Hi,

    JavaScript is entered into a web resource and then uploaded to CRM. This can then be referenced from an entity forms Properties.

    Once a web resource has been loaded on the form you can begin adding function calls to the OnLoad event under Properties, and also to field OnChange events.

    When calling the function you simply select the javascript library, enter the function name, and pass any parameters.

    Here is a step by step on adding javascript to a form:
    http://www.magnetism.co.nz/blog/11-01-05/JavaScript_Libraries_on_a_Form_in_Dynamics_CRM_2011.aspx

    Hope that helps!

    -Paul


    3. september 2012 01:16
  • Settings -> Customizations -> Customize the System -> Look for Web Resources in the left navigation

    You can create a JavaScript file defining methods you wish to call from different form/field events. 

    Web Resources for Microsoft Dynamics CRM

    Microsoft Dynamics CRM 2011 Software Development Kit

    In your example your JavaScript file might look like this:

    function ValidateLastname() {
         //Do work
    }
    

    On your contact form, when in customize mode, you can add a reference to your web resource script file by adding it under the form properties.

    Then when you are customizing the form, on the last name field you can edit the field properties and bind the ValidateLastname method to the OnChange event of the field. 

    Make sure and publish both the web resource and the form before testing.


    Jason Lattimer

    3. september 2012 01:26
    Redaktør