How to: Grab Id of Row in Context and append to URL

  • 1
  • Question
  • Updated 2 years ago
  • Answered
I'd like to create a custom hyperlink field that would grab the Id from the row in context and append it to the URL.

Example Table:
Account 1    www.example.com/Account1Id
Account 2    www.example.com/Account2Id
Account 3    www.example.com/Account3Id

I've tried using a HTML template field, but that doesn't exactly work. My JS knowledge is very limited. Can anyone point me in the right direction? 
Photo of Josef Lagorio

Josef Lagorio

  • 262 Points 250 badge 2x thumb

Posted 2 years ago

  • 1
Photo of Mark DeSimone

Mark DeSimone, Official Rep

  • 11,040 Points 10k badge 2x thumb
Hi Josef, if you'd like this to be part of a table, you can do the following:
Click on your table > Add Field(s) > Template. This will add a template field to your table, which you can manipulate to display in many different ways.
Click on the new Template Field that was just added, and up in the Properties pane, check the "Allow HTML" checkbox. Then, just above that checkbox, you can add HTML like the following:
<a href="https://foo.na35.visual.force.com/{{{Id}}}">link</a>
You would replace everything up to the / with the portion of the URL that precedes the ID number. Using {{{Id}}} will insert the record's id number as text-only. (i.e. without any Salesforce metadata)

If you're not using a table, you can take this kind of approach with a "template" component as well. Hope this helps!
(Edited)
Photo of Josef Lagorio

Josef Lagorio

  • 262 Points 250 badge 2x thumb
Thank you! I was using double "{" instead of triple..