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) »
  • Developer Discussion »
  • Report and Search UI Discussion (Moderators: CiviTeacher.com, TwoMice) »
  • Issue with custom search with multiple recs for same contact id
Pages: [1]

Author Topic: Issue with custom search with multiple recs for same contact id  (Read 1311 times)

SarahG (FountainTribe)

  • Ask me questions
  • ****
  • Posts: 782
  • Karma: 29
  • CiviCRM version: 4.4.7
  • CMS version: Drupal 6, Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Issue with custom search with multiple recs for same contact id
February 28, 2013, 09:59:50 pm
I have created a custom search that lists parents of children in certain groups/classrooms/grades.  There is one row for each parent, which also lists the name of the child and other basic info.  The search itself works in so far as it displays the correct records.   However, if I choose the action "Create PDF Letter" then I only get one letter per parent, not one letter per row.

For example, I run the custom search and see the results listing  25 rows. However, I only get 15 PDF letters.  The "missing" letters are for individuals who are listed in multiple rows due to the fact they have more than one child. ( which is a very common situation.)

My current work-around is to have the end-user export the results to Excel, then do a mail-merge in Excel. The export produces 25 rows as expected.

What I was trying to do: Create a new custom action using hooks, to use instead of Create PDF Letter and Send Email. However, this is not working as the custom action simply gets an array of 15 contact IDs. I was thinking I could pass another id other than contact id (such as relationship id, or parent contact id concated with the child's contact id, etc.)   But the custom action and the build-in actions always seem to expect contact IDs.

Any ideas on the best way to tackle this issue? Seems like it would come up anytime there is a contact listed multiple times in the resulting rows.

BTW: I am also using some custom mail merge tokens, such as {parent_name}  and {child_name}  in the PDF Letter/email to produce a letter as follows:
--------------------------------------------------------------
Dear George Jetson,

Your child, Elroy Jetson has a parent-teacher conference  next week. We look forward to seeing you.

----------------------------------------------------------------------------
Dear George Jetson,

Your child, Judy Jetson has a parent-teacher conference  next week. We look forward to seeing you.

------------------------------

So a closely related problem is the custom token needs to know which row someone was on so it can get the details for the correct child.  This is failing too, as the hook for mail merge tokens only includes an array of contact ids for the parents.
« Last Edit: March 01, 2013, 11:39:42 am by epg »
Did I help you? Please donate to the Civi-Make-It-Happen campaign  CiviCRM for mobile devices! 

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: Issue with custom search with multiple recs for same contact id
March 01, 2013, 07:10:16 am

The current interfaces for "contact search" (including tokens) assume only 1 uniq id (i.e. contact id). We'll need to change the protocol and make it a bit more extensible, something like:

uniq is == (contact id + (entity table, entity id))

(which will allow the below scenario and also things like multiple activities / contact in activity search etc)

This is a fairly big change and will need to be spec'ed designed and implemented. Cant think of any short / quick hacks,but i'll sleep on it

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

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • Report and Search UI Discussion (Moderators: CiviTeacher.com, TwoMice) »
  • Issue with custom search with multiple recs for same contact id

This forum was archived on 2017-11-26.