Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8773935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:26:02+00:00 2026-06-13T18:26:02+00:00

I have a comments String field in my domain. On each save or update

  • 0

I have a “comments” String field in my domain. On each save or update of the field I want to check if the field contains a sub string that matches a String from another field of the same domain (or different domain for that matter). I need to run through all the instances of that field to see if there is a match. If it matches I want to transform it into a link inside the comments field to a show action for that entry matching the sub string.

So for example, a comments field for a product with a serial number would note if the product has been replaced by another one by giving it’s serial number in the comments field. Like: “This product was replaced by SN1234”. I want to automatically transform SN1234 into a link to show the product with serial number SN1234.

What is the best way to go about this ? In the controller, in the GSP ? How ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T18:26:04+00:00Added an answer on June 13, 2026 at 6:26 pm

    As long as the column you’re trying to match on is indexed, you’ll just need to do a query for the match and if found, modify your comment to include the URL. Controller or Service doesn’t really matter for the lookup (although I would probably put it in a service). You’ll want to be sure the search is not transactional so it will be as fast as it can be. No way I would do any of this in a GSP.

    To insert the link, you could a simple find and replace. Once you know which text you want turned into the link, pseudo code follows:

    def comment = "This product was replaced by SN1234" 
    def match = "SN1234"
    def link = g.link(action: "show", controller: "product", id: "${product.id}", match)
    comment = comment.replace(match, link)
    

    Which you would then end up with

    "This product was replaced by <a href='/product/1234'>SN1234</a>"
    

    There may be more efficient ways to do this, but this is a good place to start.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a long string of comments that I'd like to split into multiple
I have this string: comment_1234 I want to extract the 1234 from the string.
I am creating a website that will have articles; each article will have comments.
Here's what I need to fetch: - posts that have comments - number of
I have facebook comments on my site. I noticed that when there are 10
I'm trying to create a site with news that can have comments. I've been
Edit, as per these comments: Do you mean "Property" vs "Field"? public String S1;
essentially I have a category that you can add comments to, this category shows
We have a string field which can contain XML or plain text. The XML
Suppose that we have a web site where each person has a profile and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.