Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM forum
Answered

Create URL Field in Contact Form with a dynamically hyperlink

Posted on by 135


Hi Everyone,

I have a requirement to create a URL field named MyUrl in contact form and a hyperlink of external system will automatically population in this field when create the contact record.
The format of the hyperlink like this: sysco.mycompany.com/ClientID/dashboard. In the hyperlink, ClientID is another field name in Contact Form and it will dynamics populated in hyperlink.

The whole process is when ClientID field is put value, MyUrl field will automatically populate the hyperlink with the dynamic ClientID value.

Any solution, workflow, Javascript is welcome and appreciated.

  • FOR365 Profile Picture
    FOR365 135 on at
    RE: Create URL Field in Contact Form with a dynamically hyperlink

    Set up successfully. Thank you so much Guido for your instruction and time.

  • Verified answer
    Guido Preite Profile Picture
    Guido Preite 54,065 Moderator on at
    RE: Create URL Field in Contact Form with a dynamically hyperlink

    if you connected the PCF control to the phone number, you need to add a secondary field for phone number field (if you are using the classic designer you will see a checkbox in the right that allow you to show the fields already added to the form), so one will contain the phone number and the other one will contain the PCF control, when the phone number is filled the PCF control should show the correct link.

    As I wrote before I don't give support for that PCF control, and the source code is on GitHub if you or a dev wants to improve it.

  • FOR365 Profile Picture
    FOR365 135 on at
    RE: Create URL Field in Contact Form with a dynamically hyperlink

    Hi Guido,

    Thank you for your response.

    I tried to use Custom URL Control PCF setting up in my system, but I meet some issue. The screenshot as below

    set-up-1.png

    set-up-2.png

    set-up-3.JPG

    The last picture shows there is a configuration error and in url the phone number is null. I can't input a phone number.

    Could you please check my setup and give me instruction how to fix it? Thanks. 

  • Guido Preite Profile Picture
    Guido Preite 54,065 Moderator on at
    RE: Create URL Field in Contact Form with a dynamically hyperlink

    1) yes

    2) if the PCF control is installed with a managed solution (as it should) it can be uninstalled only if is not used inside the system

    3) no, updates are not mandatory

    if you want to use a webresource to display the link that is an alternative to a PCF control, it's a different way to implement the requirement (it works) but needs to be written and configured in a different way, the code you posted is not enough.

    As I wrote before I don't give support to the PCF control I created, however, after you installed it, it will appear under the "Controls" section if the field type is compatible, here you can find some instructions on how to configure a PCF control srirambalajitech.blogspot.com/.../autocomplete-pcf-control.html

    that settings appear only after you imported the solution and configuring the properties after the field is selected.

  • FOR365 Profile Picture
    FOR365 135 on at
    RE: Create URL Field in Contact Form with a dynamically hyperlink

    Hi Guido,

    I try to import Custom URL Control solution into my CRM. Before that I have to do some setting up. I don't know how to go to setting up page showing in your doc. Could you give me a instruction? Thanks.

    Capture2222.JPG

  • FOR365 Profile Picture
    FOR365 135 on at
    RE: Create URL Field in Contact Form with a dynamically hyperlink

    The PCF looks perfect. Thanks so much.

    I have little experience of PCF, after read related docs, I have several questions, can you please gave me explanations?

    1. Can I deploy the PCF control in production environment?

    2. If the owner/author of the PCF delete his/her control, is there any impact to the corresponding control in our system?

    3. If the PCF control updated, do I need to update it in our system?

    Other questions, I want to insert a HTML Webresource in Contact form's header to display text hyperlink, that is 'Go to Client' with the dynamically populated ClintID. I try to write some code (borrow your JS Code) as below, but it is not work. Can you please point out which places are not correct. Thanks in advance.

    <html lang="en">

    <head>

     <meta charset="UTF-8">

     <meta http-equiv="X-UA-Compatible" content="IE=edge">

     <meta name="viewport" content="width=device-width, initial-scale=1.0">

     <title></title>

     <script>

       function setUrl (executionContext) {

         var formContext = executionContext.getFormContext();

         var clindId = form.getAttribute("new_clindid").getValue();

         var fullUrl = "";

         fullUrl = "sysco.mycompany.com/" + clindId + "/dashboard";

       }

     </script>

    </head>

    <body>

       <p>CLIENT</p>

       <a href = "fullUrl">Go to Client</a>

    </body>

    </html>

  • Guido Preite Profile Picture
    Guido Preite 54,065 Moderator on at
    RE: Create URL Field in Contact Form with a dynamically hyperlink

    accessing the data outside the form is for example if you need to extract the data to an excel file and you would like to have the url inside the data exported as well.

    if you want to have a hyperlink text you can use a PCF control, while ago I created this one

    pcf.gallery/.../

    but I don't give support on it, also my suggestion is to don't use the two Font Awesome properties as they can cause issues in the rendering

  • FOR365 Profile Picture
    FOR365 135 on at
    RE: Create URL Field in Contact Form with a dynamically hyperlink

    Hi Guido,

    Thank you for responding and the JS approach.

    Our application scenario is just dynamically add ClientID in the hyperlink which is rendered in the URL field. When user can click to go to the hyperlink page.

    I'm not this process do not deal with shore or not. Could you please give me a specific example of access out of form base on my scenario?

    Further requirement, now the user click the "earth icon" at the end of the URL field to go to hyperlink page. Is there any way to replace hyperlink (e.g. https://sysco.mycompany.com/clientid/dashboard) with a hyperlink text (e.g. 'Go to client') and user can click directly to open a page? Not have to click the "earth icon".

    Could you give an advice? Thanks.

  • Suggested answer
    Guido Preite Profile Picture
    Guido Preite 54,065 Moderator on at
    RE: Create URL Field in Contact Form with a dynamically hyperlink

    depends if you need to store the value of this link or not (meaning if needs to be accessed also outside the form, like a report, another integration,...)

    if you don't need to store the value, you can use javascript, something like this:

    function setUrl(executionContext)

    {

    var formContext = executionContext.getFormContext();

    var clientId = formContext.getAttribute("new_clientid").getValue();

    var fullUrl = "sysco.mycompany.com/" + clientId + "/dashboard";

    formContext.getAttribute("new_urlfield").setValue(fullUrl);

    }

    and this function to be called on the load event and when the client id field change (note: this is just a sample javascript to show how it can be done, doesn't mean it is the best javascript solution to implement this requirement)

    if you don't need to store the value another alternative is a PCF control but for your scenario can be an overkill.

    if you need to store the value it can be done with a workflow or with a plugin

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,558 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,645 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans