How to format a lookup field from within a template

  • 1
  • Question
  • Updated 4 years ago
  • Answered
I am a fan of using both the Field Renderer and Display Template to give context.
<field id="Business_State__c" type="REFPICK" displaytemplate="{{Name}}  {{State_Code_c__c}}">
<filters/>
</field>
This gives me a great picklist that shows the state code and also the full state name.

This field features in a template:
<field type="COMBO" allowhtml="false">
<label>{{$Label.Business_Address}}</label> <template>{{Business_Address_1__c}} {{Business_Address_2__c}} {{Business_Address_3__c}} {{Business_City__c}} {{Business_State__c}} {{Business_Zip_Postal_Code__c}} {{Business_Country2__c}} </template> </field>
Which looks like this:

  1. Can I include the picklist formatting from the first example in the template?
  2. If so, can the picklist (with the 2 field Display Template) only appear on the popup, and not on the read layout?
  3. Can the lines that are missing in the above example not show on the read layout?
Photo of Ross James

Ross James

  • 490 Points 250 badge 2x thumb

Posted 4 years ago

  • 1
Photo of Glenn Elliott

Glenn Elliott, Champion

  • 7,738 Points 5k badge 2x thumb
Well hello there Ross ...

On your point 3. We do something similar by using a bit more Mustache syntax like this:

{{#Business_Address_2__c}}{{Business_Address_2__c}}{{/Business_Address_2__c}}

which basically says "if Business_Address_2__c exists, then render it". 

To get all the line breaks and spaces just right, we have HTML and Mustache in our address template like this:

{{#ShippingCity}}
    <div>Location Address</div>
    <div>{{#ShippingStreet}}{{ShippingStreet}}{{/ShippingStreet}}</div>
    <div>{{ShippingCity}} {{#ShippingState}}{{ShippingState}} {{/ShippingState}}{{ShippingPostalCode}}</div>
    {{#ShippingCountry}}<div>{{ShippingCountry}}</div>{{/ShippingCountry}}
{{/ShippingCity}}
(Edited)
Photo of Ross James

Ross James

  • 490 Points 250 badge 2x thumb
Hello Glenn!

Thanks for this. With the news from Emily on soon being able to edit the popup, this may just be the ticket!
Photo of Emily Davis

Emily Davis, Employee

  • 3,502 Points 3k badge 2x thumb
Hey, Ross,
Glenn's advice is good for conditionally displaying certain fields. Unfortunately, there is no way to control how fields render in the template popup currently. I think it would be a great idea, though (and I think other customers would agree)! You should suggest it in our community.
Emily
Photo of Emily Davis

Emily Davis, Employee

  • 3,502 Points 3k badge 2x thumb
Good news! I just found out that Skuid's Summer 14 release will allow you to customize the edit popup on template fields! Yay!
Photo of Ross James

Ross James

  • 490 Points 250 badge 2x thumb
Hi Emily

This is very good news indeed. Can't wait!