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 »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Adding ContactID to basic search
Pages: [1]

Author Topic: Adding ContactID to basic search  (Read 1153 times)

darkchild

  • I post occasionally
  • **
  • Posts: 33
  • Karma: 2
  • “…more than kisses, letters mingle souls…”- John D
  • CiviCRM version: 4.0.1
  • CMS version: joomla & drupal
  • MySQL version: 5.0.91
  • PHP version: 5.2.14
Adding ContactID to basic search
November 12, 2011, 01:22:08 pm
Has anyone been able to modify basic search so that includes search for contact id as opposed to just name/email?

Any ideas or help with this would be appreciated.

p.s. I did a quick search but didn't find anything related.

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Adding ContactID to basic search
November 12, 2011, 02:29:19 pm
You might find this blog regarding creating a block to search by Case ID useful. I suspect it would be easy to adapt to search on Contact ID instead.

http://civicrm.org/blogs/dave-d/quicksearch-id
Protect your investment in CiviCRM by  becoming a Member!

darkchild

  • I post occasionally
  • **
  • Posts: 33
  • Karma: 2
  • “…more than kisses, letters mingle souls…”- John D
  • CiviCRM version: 4.0.1
  • CMS version: joomla & drupal
  • MySQL version: 5.0.91
  • PHP version: 5.2.14
Re: Adding ContactID to basic search
November 12, 2011, 04:04:35 pm
Thanks...checking it out now

darkchild

  • I post occasionally
  • **
  • Posts: 33
  • Karma: 2
  • “…more than kisses, letters mingle souls…”- John D
  • CiviCRM version: 4.0.1
  • CMS version: joomla & drupal
  • MySQL version: 5.0.91
  • PHP version: 5.2.14
Re: Adding ContactID/ External ID to basic search
November 23, 2011, 04:04:21 am
Hi still having problems with this. The example pointed looks like  specific to Drupal. I am using Joomla and I am just looking at creating a custom search by Contact_ID &  External ID....

I am not a coder but looked at some code in the individual php file and some custom search examples came up with this :
Code: [Select]
    function buildForm( &$form ) {
  $form->add('text', 'external_identifier', ts('External Id'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'external_identifier') );

I then assigned 'external_identifier' to the form elements and of course its not working. Please help.

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Adding ContactID to basic search
November 23, 2011, 11:38:42 am
Not sure if you're trying to search on the 'internal' Contact ID (automatically assigned unique ID displayed at bottom of contact summary -> "CiviCRM ID: 102"), OR the user entered 'External Identifier'.

If you want to search by internal contact ID - one easy approach is to create a custom copy of either the Constituent Summary Report or Constituent Detail Report (or both), and make the following tiny change in this section:

Code: [Select]
                          'filters'   =>             
                          array( 'id'           =>
                                 array( 'title'      => ts( 'Contact ID' ),
                                        'no_display' => false ),
                                 'sort_name' =>
                                 array( 'title'      => ts( 'Contact Name' ),),),

Just change no_display from true to false, as shown in the 4th line above. That will give you a nice Contact ID search field in the filters section of the report. You can filter the report by a single contact id or a range (i.e. contact id greater than or equal to N).
-----------

If you want to find records by External Identifier, you can similarly do this with a small modification to the existing Full Text custom search (might be other ways - but this one seemed pretty straightforward). In CRM/Contact/Form/Search/Custom/FullText.php add a single line in the $tables array as shown below to include external_identifier. This change, plus selecting Contacts as your table in the form should result in the search returning contacts with matching full or partial external identifiers.

Code: [Select]
            array( 'civicrm_contact' => array( 'id' => 'id',
                                               'fields' => array( 'sort_name' => null,
                                                                  'external_identifier' => null,
                                                                  'nick_name'    => null,
                                                                  'display_name' => null, ) ),

HTH.
« Last Edit: November 23, 2011, 11:40:39 am by Dave Greenberg »
Protect your investment in CiviCRM by  becoming a Member!

darkchild

  • I post occasionally
  • **
  • Posts: 33
  • Karma: 2
  • “…more than kisses, letters mingle souls…”- John D
  • CiviCRM version: 4.0.1
  • CMS version: joomla & drupal
  • MySQL version: 5.0.91
  • PHP version: 5.2.14
Re: Adding ContactID to basic search
November 23, 2011, 04:33:47 pm
Thank you David. You are a lifesaver. I implemented option 2 for both internal id and external identifier. Edited fullText.php as follows:

Code: [Select]
$tables =
            array( 'civicrm_contact' => array( 'id' => 'id',
                                               'fields' => array( 'sort_name' => null,
                      'external_identifier' => null,
                                                                  'id'    => null,
                                                                  'display_name' => null, ) ),
So now full text searches both Internal ID and External Identifier. I also modified FullText.tpl to include contact id in the results. I am still trying to get it  to show External ID as well but no luck yet.
Code: [Select]
           {foreach from=$summary.Contact item=row}
                    <tr class="{cycle values="odd-row,even-row"}">
                     <td>{$row.contact_id}</td>     
                                                       
                        <td><a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$row.contact_id`&context=fulltext&key=`$qfKey`"}" title="{ts}View contact details{/ts}">{$row.sort_name}</a></td>
                           <td>{$row.contact_address}</td>
                          <td><a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$row.contact_id`&context=fulltext&key=`$qfKey`"}">{ts}View{/ts}</a></td>
                    </tr>
                {/foreach}

Thank you so much for your help!!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Adding ContactID to basic search

This forum was archived on 2017-11-26.