This blog is also on the Microsoft Dynamics Community

Ignore the added https in a Text Field type URL

Since Dynamics 365 version 2016 (8.0), text fields with type URL get automatically https added in front of the URL if the user has not typed that. In previous versions of Dynamics 365 / CRM this addition was http. Since a lot of websites still don’t have secure certificates and don’t do https, we want Dynamics 365 to use http instead of https.With a simple JavaScript Web Resource, we can apply the old functionality as we used to have it. These 6 lines of code fire when an URL is typed in by the user, so the URL gets http as addition instead of https.

Make it work

In order to make this work, we first need to add the JavaScript Web Resource into Dynamics 365. So open your Dynamics 365 environment and go to your customization (either a solution or the default customizations). Now go to Web Resources and add a new Web Resource. Give the Web Resource any name you want to and upload the file that can be downloaded at the bottom of this page. Save and publish the Web Resource.

Next, go to the form on which you want this functionality and start editing this form. Open the Form Properties and add the Form Library you just created. After you clicked ok, you open the properties of the URL field and go to the Events tab. Add an Event Handler in which you select your library, set the Function field to ‘setHttp’ and check the ‘Pass execution contact as first parameter’. Now click ok, close all and publish your customizations.

That’s it! You’re good to go now. Please keep in mind that Dynamics 365 can sometimes experience some caching issues. When you open the form next time and you get a scripting error, please press Ctrl+F5 once. The scripting error should be gone now.

The code

UPDATE (2018): Since there have been some changes in javascript actions since Dynamics 365 v9.0, there is a new script for the v9.0 and above organisations.