Adding Javascript Functions Using Code Editor

Adding Javascript Functions Using Code Editor

Here is the second part of my ClickDimensions Code Editor blog. The first part of my blog talks about Styling ClickDimensions Web Forms using Code Editor. For the second part, I’ll show you how to use the code editor to add Javascript functions.

There are some cases wherein you need custom actions on your web form components. Form field is not the same as the event handler of the Dynamics CRM fields. We need to use the code editor to apply Javascript on your form fields. To give you a basic example, I will show you how to hide a textbox based on your dropdown list value.

Here are my fields:

The “Please specify *” textbox will only appear if “Other” is selected from the dropdown list. Otherwise, it will be hidden.

Before we proceed in constructing our javascript, we need the ID of our fields. You can check my way in getting the field IDs on the first part of my blog.

As best practice, you need to encapsulate your code inside this:

This way, your code will not be triggered on load of your web forms.

Here is my code:

Note: For the jQuery code to work, I need to replace $ to clickd_jquery.

To explain the code,
#f_3619cd88192be71180fe3863bb367d68  is the field ID of the drop-down list. I used its change event to trigger the code when the field’s value is changed.
#f_a3ead8a71a2be71181033863bb367e08  is the field ID of the text box. To set the visibility of the textbox, I used its hide/show method.

Paste the code in your JavaScript Code Editor.

Save the Code Editor window, as well as the form and see if it works.

When it comes to web forms, Javascript is always present. It’s a good thing that in ClickDimensions, there’s a code editor we could use to enhance and add more functions to the Web Form components. This is very helpful as most of the clients may require functions that are not included out-of-the-box. But let’s keep in mind the important note coming from ClickDimensions itself when using Javascript for your web forms.

Feel free to add a comment for any clarifications or questions.

Published at Tue, 27 Jun 2017 17:00:41 +0000

Leave a Reply

Your email address will not be published. Required fields are marked *