CMS Development

SStrachan
Participant

How to pass an ID

How do I pass an ID?

SStrachan_0-1635108201037.png

{{ contact.last_show_broker }}
<br>
{% set broker = crm_object("affiliate", 414750544) %}
{{ broker.firstname }}

 

The contact.last_show_broker property contains the ID

I need the set broker = crm_object("affiliate" ID to be what ever is stored in the property

0 Upvotes
7 Replies 7
piersg
Key Advisor

How to pass an ID

I'm not sure to be honest. If you return {{broker}} instead of {{broker.firstname}} what properties do you get?

 

It may be that you have to make sure anything you want to display is available in searchable properties in the schema. It looks like you can have one property in multiple property types, e.g. from one of the samples on that documentation page:

 

...
"primaryDisplayProperty": "model",
  "secondaryDisplayProperties": [
     "make"
],
  "searchableProperties": [
     "year",
     "make",
     "vin",
     "model"
],
  "requiredProperties": [
     "year",
     "make",
     "vin",
     "model"
  ],
...

 

 

0 Upvotes
SStrachan
Participant

How to pass an ID

I have this working now, but I am only able to show searchable properties. How can I display the other properties? Documentation here

 

For example I can show First Name and Last Name, but not Title?

 

 

0 Upvotes
piersg
Key Advisor

How to pass an ID

Cool, converting to an integer should (hopefully) work:

{% set broker = crm_object("affiliate", contact.last_show_broker|int) %}
{{ broker.firstname }}

 

piersg
Key Advisor

How to pass an ID

If you pretty print contact.last_show_broker what do you get? i.e. {{contact.last_show_broker|pprint}}

0 Upvotes
SStrachan
Participant

How to pass an ID

@piersg 

Here is the output
(String: 447414060)

0 Upvotes
SStrachan
Participant

How to pass an ID

Hi @piersg 
contact.last_show_broker is just a Single-line text string 

This does not work.

{% set broker = crm_object("affiliate", contact.last_show_broker) %}
{{ broker.firstname }}

 

0 Upvotes
piersg
Key Advisor

How to pass an ID

Hi @SStrachan, you say contact.last_show_broker contains the id so I'm assuming it's a dictionary with id and some other properties i.e. you would chain the id property (probably just called "id" but check that) to the end: contact.last_show_broker.id

 

So, you just need to do

{% set broker = crm_object("affiliate", contact.last_show_broker.id) %}
{{ broker.firstname }}