Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

Twitter handle on Contact form as URL field

(0) ShareShare
ReportReport
Posted on by 5

Hi there, I'd like to create a custom field on my Contact form that stores a person's Twitter handle. Ideally, I'd like it to be a URL field so that it is clickable. However, I cannot find a way to customise the URL prefix to https://twitter.com/ so that the only information needed in the field is the Twitter handle itself. Any ideas for how to do this, or to auto-populate a text string to the start of a single line of text field? Thank you!

  • SL_sws Profile Picture
    5 on at
    RE: Twitter handle on Contact form as URL field

    Hi Leo, thanks so much for your help. Unfortunately I'm not having much luck, I think because I'm not referencing the correct element id. As per below, the only div id that I can find is "sws_twitter", but it doesn't work. Any suggestions of where I'm going wrong? Thanks!

    5417.Untitled.png

  • Suggested answer
    LeoAlt Profile Picture
    16,331 Moderator on at
    RE: Twitter handle on Contact form as URL field

    Hi partner,

    It is possible to do with some custom JS code.

    As your requirement, I created a new custom string field named "Twitter Handle" in my contact form, and added the following code in the form onload event.

    function urlField(executionContext){
        var formContext = executionContext.getFormContext();
        var coreformURL = formContext.getAttribute("new_twitterhandle").getValue();
        var interval;
        interval = setInterval(function () { 
            var dom=window.parent.document.getElementById("id-1fed44d1-ae68-4a41-bd2b-f13acac4acfa-2-new_twitterhandle6-new_twitterhandle.fieldControl-text-box-container");
            if(dom!=null){
                var btnHTML = ""   coreformURL   "";
                dom.innerHTML = btnHTML;
                clearInterval(interval); 
            }
         }, 5000);
        
    }

    pastedimage1583301351860v2.png

    pastedimage1583301290604v1.png

    Save and publish.

    Then I click on the twitter handle value, the browser will open a new tab to show the link.

    pastedimage1583306209003v3.png

    pastedimage1583306227066v4.png

    Attention that the DOM element id should be found follow the below steps.

    Open F12 developer tools and find the container element id.

    pastedimage1583306378735v5.png

    And using DOM directly in D365 is not supported, it may cause some other problems in web client.

    Hope it helps.

    Best Regards,

    Leo

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Siv Sagar Profile Picture

Siv Sagar 149 Super User 2025 Season 1

#2
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 67 Most Valuable Professional

#3
Mansi Soni Profile Picture

Mansi Soni 64

Overall leaderboard

Product updates

Dynamics 365 release plans