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!
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!
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); }
Save and publish.
Then I click on the twitter handle value, the browser will open a new tab to show the link.
Attention that the DOM element id should be found follow the below steps.
Open F12 developer tools and find the container element id.
And using DOM directly in D365 is not supported, it may cause some other problems in web client.
Hope it helps.
Best Regards,
Leo
Siv Sagar
149
Super User 2025 Season 1
Muhammad Shahzad Sh...
67
Most Valuable Professional
Mansi Soni
64