Answers.Body: <p>We have done work that is hopefully heading to Civi core which makes the following possible:</p>
  
  <p>Below is the table of field name vs params that can be used in the URL to force the search results.</p>
  
  <p><strong>Contribution Tokens</strong></p>
  
  <p>Field Name > > Param in URL</p>
  
  <p>contribution_page_id > > pid</p>
  
  <p>financial_type_id > > fid</p>
  
  <p>contribution_status_id > > status</p>
  
  <p>is_pay_later > > pay_later</p>
  
  <p>receive_date_from > > (receive_date)    start</p>
  
  <p>receive_date_to > > (receive_date)  end</p>
  
  <p>Eg of complete search URL -</p>
  
  <p>"civicrm/contribute/search?reset=1&amp;force=1&amp;status=1&amp;fid=2&amp;pay_later=1&amp;start=20181206&amp;end=20181210"</p>
  
  <p><strong>Membership Tokens</strong></p>
  
  <p>Field Name > > Param in URL</p>
  
  <p>membership_type_id > > type</p>
  
  <p>membership_status_id > > status</p>
  
  <p>start_date > > start &amp; start_high</p>
  
  <p>end_date > > end &amp; end_high</p>
  
  <p>Eg of complete search URL -</p>
  
  <p>"civicrm/member/search?reset=1&amp;force=1&amp;type=1&amp;status=1&amp;start=20181002&amp;start_high=20181004&amp;end=20181103&amp;end_high=20181109"</p>
  
  <p><strong>Participant Tokens</strong></p>
  
  <p>Field Name > > Param in URL</p>
  
  <p>event_id > > event</p>
  
  <p>status_id > > status</p>
  
  <p>role_id > > role</p>
  
  <p>is_pay_later > > pay_later</p>
  
  <p>register_date_from > > register_start</p>
  
  <p>register_date_to > > register_end</p>
  
  <p>Eg of complete search URL -</p>
  
  <p>"civicrm/event/search?reset=1&amp;force=1&amp;event=1&amp;status=2&amp;role=3&amp;pay_later=1&amp;register_start=20181210&amp;register_end=20181214"</p>
  
  <p><strong>Activity Tokens</strong></p>
  
  <p>Field Name  Param in URL</p>
  
  <p>activity-type id > > type</p>
  
  <p>activity_status > > status</p>
  
  <p>has a follow-up activity > > hasFollowUp</p>
  
  <p>is a follow-up acivity > > isFollowUp</p>
  
  <p>start date > > dateLow</p>
  
  <p>end date > > dateHigh</p>
  
  <p>Eg of complete search URL -</p>
  
  <p>civicrm/activity/search?reset=1&amp;force=1&amp;status=1&amp;hasFollowUp=1&amp;isFollowUp=1&amp;dateLow=20181210&amp;dateHigh=20181212&amp;type=3</p>
  
  <p>Here is the link to the gitlab ticket <a href="https://lab.civicrm.org/dev/core/issues/252" rel="nofollow noreferrer">https://lab.civicrm.org/dev/core/issues/252</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-20T22:35:44.127Z
Answers.LastActivityDate: 2018-07-20T23:26:29.557Z
Answers.LastEditDate: 2018-07-20T23:26:29.557Z
Answers.UserDisplayName: petednz - fuzion
Answers.Body: <p>Another way would be to use the api in your extension to create a group out of the results, then redirect to the group's group page, which has the same actions dropdown that search results does.</p>
  
  <p>You might end up with a lot of stale groups lying around, but you could have a cron script delete the groups daily or something like that.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-20T16:28:22.140Z
Answers.LastActivityDate: 2018-07-20T16:28:22.140Z
Answers.UserDisplayName: Demerit
Answers.Body: <p>If you rejig your extension so that your filtering is done via "custom search" then you automatically get that. See <a href="https://docs.civicrm.org/dev/en/latest/extensions/civix/#generate-search" rel="nofollow noreferrer">https://docs.civicrm.org/dev/en/latest/extensions/civix/#generate-search</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-19T18:08:40.217Z
Answers.Text: Thanks! Unfortunately that's not quite how my extension works - there's a lot of API work, which custom searches don't like very much. Is it possible to fire a list of contact IDs at a page?
Answers.UserDisplayName: Andrew West
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-19T18:46:47.130Z
Answers.Text: I haven't tested this but I suppose you could write a separate very simple custom search which takes as input a comma-separated list of ids, then do a redirect to it from your existing extension with force=1, e.g. CRM_Utils_System::redirect( CRM_Utils_System::url('civicrm/contact/search/custom', "reset=1&force=1&csid={$myCustomSearchId}&inputField={$csvListOfIds}")); where inputField is whatever you call the form field that takes the list of ids in the custom search. You might not even need a field just retrieve directly from the url. It's clunky - maybe somebody else has better.
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-20T08:47:35.607Z
Answers.Text: You may be able to use the search builder to post a comma separated list of IDs when using the search criteria "contact id IN".
Answers.UserDisplayName: Thomas Schüttler
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-19T14:42:42.833Z
Answers.LastActivityDate: 2018-07-19T14:42:42.833Z
Answers.UserDisplayName: Demerit
Body: <p>I have an extension that lets people filter contacts in various ways. I'd like them to be able to click to show these contacts in a standard Civi results page - with the action box at the top etc. So that they can manipulate them in the normal ways, by adding to groups and such.</p>
  
  <p>Is there a recommended way to do this, programatically?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-07-19T20:13:10.973Z
Comments.Text: we have done some work to enable lots of elements be filtered via the url so menu links can be set up - if that sounds useful i will dig out the documentation
Comments.UserDisplayName: petednz - fuzion
Tags: <search>
Title: How can I generate a search results page from a list of contact IDs, programatically?
ThreadText: # How can I generate a search results page from a list of contact IDs, programatically?
  
  (Asked by: username_0 on 2018-07-19)
  
  I have an extension that lets people filter contacts in various ways. I'd like them to be able to click to show these contacts in a standard Civi results page - with the action box at the top etc. So that they can manipulate them in the normal ways, by adding to groups and such.
  
  Is there a recommended way to do this, programatically?
  
  **Tags:** search
  
  > **Comments:**
  > **username_1**: we have done some work to enable lots of elements be filtered via the url so menu links can be set up - if that sounds useful i will dig out the documentation  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_1 on 2018-07-20. Score: 2
  
  We have done work that is hopefully heading to Civi core which makes the following possible:
  
  Below is the table of field name vs params that can be used in the URL to force the search results.
  
  **Contribution Tokens**
  
  Field Name > > Param in URL
  
  contribution\_page\_id > > pid
  
  financial\_type\_id > > fid
  
  contribution\_status\_id > > status
  
  is\_pay\_later > > pay\_later
  
  receive\_date\_from > > (receive\_date) start
  
  receive\_date\_to > > (receive\_date) end
  
  Eg of complete search URL -
  
  "civicrm/contribute/search?reset=1&force=1&status=1&fid=2&pay\_later=1&start=20181206&end=20181210"
  
  **Membership Tokens**
  
  Field Name > > Param in URL
  
  membership\_type\_id > > type
  
  membership\_status\_id > > status
  
  start\_date > > start & start\_high
  
  end\_date > > end & end\_high
  
  Eg of complete search URL -
  
  "civicrm/member/search?reset=1&force=1&type=1&status=1&start=20181002&start\_high=20181004&end=20181103&end\_high=20181109"
  
  **Participant Tokens**
  
  Field Name > > Param in URL
  
  event\_id > > event
  
  status\_id > > status
  
  role\_id > > role
  
  is\_pay\_later > > pay\_later
  
  register\_date\_from > > register\_start
  
  register\_date\_to > > register\_end
  
  Eg of complete search URL -
  
  "civicrm/event/search?reset=1&force=1&event=1&status=2&role=3&pay\_later=1&register\_start=20181210&register\_end=20181214"
  
  **Activity Tokens**
  
  Field Name Param in URL
  
  activity-type id > > type
  
  activity\_status > > status
  
  has a follow-up activity > > hasFollowUp
  
  is a follow-up acivity > > isFollowUp
  
  start date > > dateLow
  
  end date > > dateHigh
  
  Eg of complete search URL -
  
  civicrm/activity/search?reset=1&force=1&status=1&hasFollowUp=1&isFollowUp=1&dateLow=20181210&dateHigh=20181212&type=3
  
  Here is the link to the gitlab ticket <https://lab.civicrm.org/dev/core/issues/252>
  
  
  ---
  
  ### Answer by username_2 on 2018-07-20. Score: 1
  
  Another way would be to use the api in your extension to create a group out of the results, then redirect to the group's group page, which has the same actions dropdown that search results does.
  
  You might end up with a lot of stale groups lying around, but you could have a cron script delete the groups daily or something like that.
  
  
  ---
  
  ### Answer by username_2 on 2018-07-19. Score: 1
  
  If you rejig your extension so that your filtering is done via "custom search" then you automatically get that. See <https://docs.civicrm.org/dev/en/latest/extensions/civix/#generate-search>
  
  > **Comments:**
  > **username_0**: Thanks! Unfortunately that's not quite how my extension works - there's a lot of API work, which custom searches don't like very much. Is it possible to fire a list of contact IDs at a page?  
  > **username_2**: I haven't tested this but I suppose you could write a separate very simple custom search which takes as input a comma-separated list of ids, then do a redirect to it from your existing extension with force=1, e.g. CRM_Utils_System::redirect( CRM_Utils_System::url('civicrm/contact/search/custom', "reset=1&force=1&csid={$myCustomSearchId}&inputField={$csvListOfIds}")); where inputField is whatever you call the form field that takes the list of ids in the custom search. You might not even need a field just retrieve directly from the url. It's clunky - maybe somebody else has better.  
  > **username_3**: You may be able to use the search builder to post a comma separated list of IDs when using the search criteria "contact id IN".  
  
  ---
  
  