Ignore the added https in a Text Field type URL

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.


function setHttp(context) {
    var webUrl = Xrm.Page.getAttribute(context.getEventSource().getName()).getValue();
    if (webUrl != null && webUrl.substring(0,7) != "http://" &&  webUrl.substring(0,7) != "https:/") {
        Xrm.Page.getAttribute(context.getEventSource().getName()).setValue("http://" + webUrl)


function setHttp(executionContext) {
    var formContext = executionContext.getFormContext();
    var webUrl = formContext.getAttribute(executionContext.getEventSource().getName()).getValue();
    if (webUrl != null && webUrl.substring(0, 7) != "http://" && webUrl.substring(0, 7) != "https:/") {
        formContext.getAttribute(executionContext.getEventSource().getName()).setValue("http://" + webUrl)

Download your file here

Download v8.0 and above

Download v9.0 and above

7 Replies to “Ignore the added https in a Text Field type URL”

  1. Tested this on Dynamics 365 on-premises (Version 1612 ( and system adds https before this code executes so it doesn’t work.

    1. Hi Kalle,

      I’ve tested in on my end with the same on-prem version and everything seems to properly work. Have you tried clearing your cache? That helps sometimes.

  2. This script isn’t working for us – do you know if it needs to be updated to accommodate dynamics 9.0? Also, we’re using the field as “website” – would that be affecting anything?

    1. Hi Whitney,

      Thanks for the heads-up! You’re right that this isn’t compliant with v9 and above. I’ve changed the javascript and it should work now 🙂

  3. Hi Marc,
    Just wondering. Can I use this method to stop Dynamics adding any kind of prefix to the website field. ? Thanks in advance

    1. Hi Alex,

      Sorry, I totally missed your message! I haven’t tried with an other prefix. Just try and you’ll know :-). What are you thinking of? Something like ftp://?


Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.