Answers.Body: <p>Davy, You can use CiviCRM api to fetch the custom fields of participants, contact and then use as smarty in your message template </p>
  
  <p>Something like this you can include in invoice template</p>
  
  <pre><code>{crmAPI var='result' entity='ParticipantPayment' action='get' return="participant_id.contact_id.custom_3,participant_id.custom_4" contribution_id=$id}
  {assign var="contactCustomField" value="participant_id.contact_id.custom_3"}
  {assign var="ParticipantCustomField" value="participant_id.custom_4"}
  {foreach from=$result.values item=participantpayment}
    &lt;tr&gt;
      &lt;td&gt;Contact custom field&lt;/td&gt;
      &lt;td&gt;{$participantpayment.$contactCustomField}&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Participant custom field&lt;/td&gt;
      &lt;td&gt;{$participantpayment.$ParticipantCustomField}&lt;/td&gt;
    &lt;/tr&gt;
  {/foreach}
  </code></pre>
  
  <p>HTH</p>
  
  <p>Pradeep</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-05-04T13:18:16.593Z
Answers.Text: Hi Pradeep - How does one fetch an 'organization contact' custom field from the 2nd contact on a webform?
  
  My webform has Contact 1 = Individual and Contact 2 = Organisation (for employer). I've added a CiviCRM custom field (organisation type) to the webform to capture the employer's tax reference number. 
  
  I can't work out how to fetch and print the tax reference number on the invoice.
  
  Thanks, Davy
Answers.UserDisplayName: Davy Ivins
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-10T16:05:17.793Z
Answers.Text: Thanks for the guidance Pradeep - although I'll need to digest what you've suggested :-)
Answers.UserDisplayName: Davy Ivins
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-20T12:28:10.450Z
Answers.Text: Thank you Pradeep. Your answer worked perfectly to include my custom fields on the Invoice
Answers.UserDisplayName: Davy Ivins
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-20T12:31:03.903Z
Answers.Text: so can you mark this as answered?
Answers.UserDisplayName: Pradeep Nayak
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-10T14:17:04.153Z
Answers.LastActivityDate: 2019-04-10T14:17:04.153Z
Answers.UserDisplayName: Pradeep Nayak
Body: <p>Drupal 7, Civi 5.12
  I have created custom fields for civievent bookings (to be used for Participants, Individual, Organization).</p>
  
  <p>Is there an easy way for a non developer to create tokens for these custom fields so that I can include them in the Contributions Invoice template?</p>
  
  <p>(I asked the same question in 2017 and found a way around by using custom contact fields, but that was kludgy).</p>
  
Tags: <civievent><drupal><tokens>
Title: How to create tokens for custom fields (participant, individual, organisation)
ThreadText: # How to create tokens for custom fields (participant, individual, organisation)
  
  (Asked by: username_0 on 2019-04-10)
  
  Drupal 7, Civi 5.12
  I have created custom fields for civievent bookings (to be used for Participants, Individual, Organization).
  
  Is there an easy way for a non developer to create tokens for these custom fields so that I can include them in the Contributions Invoice template?
  
  (I asked the same question in 2017 and found a way around by using custom contact fields, but that was kludgy).
  
  **Tags:** civievent, drupal, tokens
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-04-10. Score: 3 | Accepted answer
  
  Davy, You can use CiviCRM api to fetch the custom fields of participants, contact and then use as smarty in your message template 
  Something like this you can include in invoice template
  {crmAPI var='result' entity='ParticipantPayment' action='get' return="participant_id.contact_id.custom_3,participant_id.custom_4" contribution_id=$id}
  {assign var="contactCustomField" value="participant_id.contact_id.custom_3"}
  {assign var="ParticipantCustomField" value="participant_id.custom_4"}
  {foreach from=$result.values item=participantpayment}
    
      Contact custom field
      {$participantpayment.$contactCustomField}
    
    
      Participant custom field
      {$participantpayment.$ParticipantCustomField}
    
  {/foreach}
  
  HTH
  Pradeep
  
  > **Comments:**
  > **username_0**: Thanks for the guidance Pradeep - although I'll need to digest what you've suggested :-)  
  > **username_0**: Thank you Pradeep. Your answer worked perfectly to include my custom fields on the Invoice  
  > **username_1**: so can you mark this as answered?  
  > **username_0**: Hi Pradeep - How does one fetch an 'organization contact' custom field from the 2nd contact on a webform?  My webform has Contact 1 = Individual and Contact 2 = Organisation (for employer). I've added a CiviCRM custom field (organisation type) to the webform to capture the employer's tax reference number.   I can't work out how to fetch and print the tax reference number on the invoice.  Thanks, Davy  
  
  ---
  
  