CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM (Moderator: Dave Greenberg) »
  • Custom Fields with multiple value - not available as tokens?
Pages: [1]

Author Topic: Custom Fields with multiple value - not available as tokens?  (Read 1557 times)

Detlev

  • I post occasionally
  • **
  • Posts: 68
  • Karma: 2
    • Software für Engagierte e.V.
  • CiviCRM version: 4.5
  • CMS version: Drupal
Custom Fields with multiple value - not available as tokens?
September 19, 2013, 12:06:35 am
I am storing some custom data within multiple value fields.

Now, I want to use this data: e.g. for a pdf letter, where I want to have a list with all the entries of the fields within the custom field set.

I can access other custom dta via tokens (such as "{contact.custom_4}"). However, it seems to me this does not work for multiple value fields: Instead of printing the values, the token gets printed (e.g. {contact.custom_12}).

Is there an easy way to access the multiple field values via tokens?

Or would you recommend another approach?

Thanks for any help!
Greetings,
Detlev


Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Custom Fields with multiple value - not available as tokens?
September 19, 2013, 07:00:34 am

You will need to do this via a token hook. Check:

http://civicrm.org/blogs/colemanw/create-your-own-tokens-fun-and-profit

u'll also need to figure out what value to return if a custom field has multiple values.

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Detlev

  • I post occasionally
  • **
  • Posts: 68
  • Karma: 2
    • Software für Engagierte e.V.
  • CiviCRM version: 4.5
  • CMS version: Drupal
Re: Custom Fields with multiple value - not available as tokens?
September 20, 2013, 03:02:18 am
You wrote:
Quote
"u'll also need to figure out what value to return if a custom field has multiple values."

Exactly this is my issue - since I need all of the multiple values of the custom fields printed out!

Example: Think of a list of educational experiences for a contact, which are saved as a multi value field (with from date, to date, name of school/university, degree). Our requirement is to print out a kind of kind of CV for the contacts (with some of these lists, for education, language skills, previous work experience, together with several other CiviCRM core fields and custom fields, all formatted in a nice way). I think, creating a pdf letter template would work best in this case...

In order to avoid double work:

Had anybody done something like a token, that creates a full list of all entries within a multi value field set?

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Custom Fields with multiple value - not available as tokens?
September 20, 2013, 10:57:52 am

dont know if someone has done this, but you should be able to find a fair bit of code that you can reuse for this in the custom search for multiple record custom fieds:

CRM/Contact/Form/Search/Custom/MultipleValues.php

maybe the token should be:

{custom_value.ALL} - for all fields in a table for that contact id
{custom_value.SPECIFIC_FIELD_NAME} - for a specific field only (or some convention to denote multiple fields)

please do share and publish this extension. will be quite useful to many

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

jaapjansma

  • I post frequently
  • ***
  • Posts: 247
  • Karma: 9
    • CiviCoop
  • CiviCRM version: 4.4.2
  • CMS version: Drupal 7
  • MySQL version: 5
  • PHP version: 5.4
Re: Custom Fields with multiple value - not available as tokens?
October 14, 2013, 08:35:32 am
On this blog you can find instructions on how to develop your custom token.
https://civicrm.org/blogs/colemanw/create-your-own-tokens-fun-and-profit
Developer at Edeveloper / CiviCoop

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM (Moderator: Dave Greenberg) »
  • Custom Fields with multiple value - not available as tokens?

This forum was archived on 2017-11-26.