web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

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!

I have the same question (0)
  • Suggested answer
    LeoAlt Profile Picture
    16,331 Moderator on at

    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

  • SL_sws Profile Picture
    5 on at

    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

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 60 Most Valuable Professional

#2
#ManoVerse Profile Picture

#ManoVerse 51

#3
Satyam Prakash Profile Picture

Satyam Prakash 42

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans