How do I override a lookup/reference field link in a template?

edited June 18, 2019 in Questions
I'm trying to create a link that takes a Skuid user to a specific page when they click on a person's name. I don't know that I necessarily want to override pages, as this will require more info than just the ID of the person's Contact record. I figured I would just make a template with an HTML anchor tag that goes to another Skuid page. Here's what my template field says: <a href="/apex/ui?seid={{Student_Enrollment__c}}&page=StudentDetail">{{Student__c}}</a> But here is what it looks like when it renders: Obviously something funky is happening with how the HTML and merge fields are interacting. What am I doing wrong?

Comments

  • edited June 18, 2019
    Short answer: wrap Student_Enrollment__c in triple mustaches / curly braces, and Skuid will output the plain, unformatted value of the Student_Enrollment__c relationship field:
    <a href="/apex/skuid__UI?page=StudentDetail&seid={{{Student_Enrollment__c}}}">{{Student__r.Name}}</a>
    Long Answer: whenever you use two curly braces around a field in a template, such as "{{Student__c}}", Skuid will look at your Model to see if there's a corresponding field, and if there is, it will use that field's metadata to try to render the raw data in an appropriate format. Examples: (Datetime) 2012-12-31 14:05:08.003Z ---> 31/12/2012 14:05 (in Britain) (Lookup field) 0030000004754AAA ---> link to Jack Black's Contact record, with Jack Black as the link text So, for your case, when you tried to put "{{Student_Enrollment__c}}" inside of an HTML link, you were actually getting a double link, because Skuid was trying to render a link to the Student_Enrollment__c record inside of your link. But, when you use triple mustaches, Skuid just spits out the raw data, not doing any rendering at all. Compare: {{{Student__c}}} ---->
    0030000004754AAA
    {{Student__c}} ---->
    <a href="/0030000004754AAA">Jack Black</a>
  • edited November 19, 2015
    Ahh, tricky, but handy! BTW, someone may want to edit the title of my post for future reference to something like "How do I override a standard field's link in a template?"
  • edited September 23, 2016
    Great, been looking for this solution!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!