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) »
  • Can I create a URL to perform a search with pre-defined criteria?
Pages: [1]

Author Topic: Can I create a URL to perform a search with pre-defined criteria?  (Read 797 times)

cscooper

  • Guest
Can I create a URL to perform a search with pre-defined criteria?
February 08, 2012, 07:42:43 pm
I would like to give my users an easy link that does a search with a set of pre-defined criteria - for example, find all contacts in a particular group.  To say it another way, when I manually do an advanced search and click on Search, it sends my search criteria as POST values, I'd like to do a search using QUERY values in the URL.

I realize my users can bring up the advanced search screen and do this in only a few mouse clicks, but I'd rather make this as fool-proof as possible.  I could also create my own HTML page that created the necessary POST values, but I'm hoping to avoid the intermediate step.

Thanks,
Chris

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Can I create a URL to perform a search with pre-defined criteria?
February 09, 2012, 04:33:28 pm
Chris - As far as I know the built-in Find Contacts and Advanced Search forms do not yet support this (although it's just been added for the 4.2 release for a limited set of advanced search Mailing related criteria).

HOWEVER, you can create a profile-based search interface which does allow you to pass in criteria (and control search result columns etc.). This may work well for your use cases. You can see a simple example on the demo. Log in to:

http://drupal.demo.civicrm.org/

Then navigate to:
http://drupal.demo.civicrm.org/civicrm/profile?reset=1&gid=1&force=1&group=2

I've passed in a group.id value in this case, but you can pass in most (or all?) fields using fieldName=value pattern. You can also hide the search form if you want (&search=0), and include link to the back-office contact summary (profile advanced settings).

http://wiki.civicrm.org/confluence/display/CRMDOC41/Linking+Profiles (Profile Search and Listings section).
Protect your investment in CiviCRM by  becoming a Member!

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: Can I create a URL to perform a search with pre-defined criteria?
February 09, 2012, 05:47:00 pm

Asuming your users have access to the search screens of civicrm, an alternative approach might be:

1. Save your search as a smart group

2. Goto manage contacts, click on contacts for that smart group

3. publish that link under a civicrm menu / drupal block etc

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

cscooper

  • Guest
Re: Can I create a URL to perform a search with pre-defined criteria?
February 11, 2012, 07:07:05 am
Excellent!  Thanks!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Can I create a URL to perform a search with pre-defined criteria?

This forum was archived on 2017-11-26.