5 Replies Latest reply on Jun 17, 2019 1:27 PM by fac586

    identifying and tagging hyperlinks in a text field

    Lee Burgess

      Hi, I'm using 18.2.

      I have various user entry fields at present which save the value of the text entered.

      On update of the record, I require the text to be checked for any valid urls and these urls to be tagged as such so they appear as a link can be opened by the user.

       

      Hope this makes sense - I'm fairly new to APEX so apologies if further clarification required.

        • 1. Re: identifying and tagging hyperlinks in a text field
          Franck N

          Hi,

           

          should the input file "Description" be editable by the user?

          how is the URL being pass tho the Item if dynamic?

           

           

          regards,

          Franck

          • 2. Re: identifying and tagging hyperlinks in a text field
            fac586

            Lee Burgess wrote:

             

            I have various user entry fields at present which save the value of the text entered.

            On update of the record, I require the text to be checked for any valid urls and these urls to be tagged as such so they appear as a link can be opened by the user.

             

            Hope this makes sense - I'm fairly new to APEX so apologies if further clarification required.

            What is the purpose of the "Description" column? How long is it? Based on its visible size the idea of it containing more than one "valid URL" looks unlikely.

             

            I would tend toward questioning the data model and/or UI:

             

            • If that page item is an accurate reflection of the expected/permitted length of the "Description" then it is clearly intended to be a single short phrase, and following 1NF it should not contain the URL. The model should provide an additional column for storing a single optional URL associated with it. The application can combine the two values to form HTML link mark-up as required.
            • If the "Description" can consist of longer form text content with optional links, then the UI should render it as a rich text editor with suitably restricted formatting options, and the content should be sanitized on submission using apex_escape.html_whitelist.
            1 person found this helpful
            • 3. Re: identifying and tagging hyperlinks in a text field
              Lee Burgess

              Hi, Thanks for the quick reply.

               

              The description field is free form and can be up to 255 characters (it is a larger box before submit so image a bit misleading). The client has asked for many of the current user-entry text fields in the app be enabled to allow the user to enter free form text including URLs. Once the record is saved I need the string to be processed and the link tags added to the URLs. The hyperlinks would then be 'clickable' (& editable)on the front end by the user I've been looking at potential solutions here: https://stackoverflow.com/questions/37162510/how-to-find-only-urls-in-huge-text-block-in-pl-sql  using REGEXP_REPLACE but unsure if this is the best solution.

               

              Again thanks for taking the time to help.

              • 4. Re: identifying and tagging hyperlinks in a text field
                Lee Burgess

                Hi Franck - Yes desciption field is fully editable, the url is pasted in/typed by the user.

                Thanks for taking the time to reply

                • 5. Re: identifying and tagging hyperlinks in a text field
                  fac586

                  Lee Burgess wrote:

                   

                  The description field is free form and can be up to 255 characters

                  That's not a lot once a couple of URLs are involved.

                  (it is a larger box before submit so image a bit misleading).

                  Yes it is. Why not post the "before submit" form? What does that look like? What are we actually looking at in the original screenshot?

                  The client has asked for many of the current user-entry text fields in the app be enabled to allow the user to enter free form text including URLs. Once the record is saved I need the string to be processed and the link tags added to the URLs. The hyperlinks would then be 'clickable'

                  It sounds like the client doesn't know much about HTML. Links are created by wrapping content in <a href="...">....</a> tags. The enclosed content becomes palpable and can be used to trigger the link. In this scenario, how are you going to determine which content is to be used as the link text?