Answers.Body: <p>Since the number of selected records hasn't updated when you check the box, that suggests it's possibly a Javascript error.  Try the steps in <a href="http://forum.civicrm.org/index.php/topic,35850" rel="nofollow">Troubleshooting JavaScript in CiviCRM</a> and post back any new diagnostic info you find.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-06T10:11:30.450Z
Answers.Text: I have ran diagnostics and reported in this thread. Because this was happening all search function not only in custom search. http://civicrm.stackexchange.com/questions/3727/javascript-prevents-search-function-selecting-result-not-enabling-action-men
Answers.UserDisplayName: Tapash
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-29T14:57:56.727Z
Answers.LastActivityDate: 2015-05-29T14:57:56.727Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.Body: <p>In 2021 is the same problem. In custom search you can't enable actions. But I find solution. I looked to the js file which count checkboxes and I found out that you just need remove &quot;crm-ajax-selection-form&quot; class from your search form. You can add to your tpl file somethink like this:
  <code>&lt;script&gt; {literal} CRM.$(&quot;.crm-ajax-selection-form&quot;).removeClass(&quot;crm-ajax-selection-form&quot;); {/literal} &lt;/script&gt;</code>
  2 hours reverse engineering was worth it. :D</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-28T18:42:14.197Z
Answers.LastActivityDate: 2021-03-28T19:15:02.363Z
Answers.LastEditDate: 2021-03-28T19:15:02.363Z
Answers.UserDisplayName: Vítek Maňásek
Answers.Body: <p>I am running into exactly the same problem (ie selecting some records does not activate the "Actions" button.  It is happening with a custom search that was generated by "civix". (I only changed the title) </p>
  
  <p>Did anyone find a solution?</p>
  
  <p>Source code is: `</p>
  
  <blockquote>
    <p>/**  * A custom contact search  */ class
    CRM_Financialsummaries_Form_Search_preparestatements extends
    CRM_Contact_Form_Search_Custom_Base implements
    CRM_Contact_Form_Search_Interface {   function
    __construct(&amp;$formValues) {
        parent::__construct($formValues);   }</p>
    
    <p>/**    * Prepare a set of search fields    *    * @param
    CRM_Core_Form $form modifiable    * @return void    */   function
    buildForm(&amp;$form) {
        CRM_Utils_System::setTitle(ts('Prepare Statements'));</p>
  
  <pre><code>$form-&gt;add('text',
    'household_name',
    ts('Household Name'),
    TRUE
  );
  
  $stateProvince = array('' =&gt; ts('- any state/province -')) + CRM_Core_PseudoConstant::stateProvince();
  $form-&gt;addElement('select', 'state_province_id', ts('State/Province'), $stateProvince);
  
  // Optionally define default search values
  $form-&gt;setDefaults(array(
    'household_name' =&gt; '',
    'state_province_id' =&gt; NULL,
  ));
  
  /**
   * if you are using the standard template, this array tells the template what elements
   * are part of the search criteria
   */
  $form-&gt;assign('elements', array('household_name', 'state_province_id'));   }
  </code></pre>
    
    <p>/**    * Get a list of summary data points    *    * @return mixed;
    NULL or array with keys:    *  - summary: string    *  - total:
    numeric    */   function summary() {
        return NULL;
        // return array(
        //   'summary' => 'This is a summary',
        //   'total' => 50.0,
        // );   }</p>
    
    <p>/**    * Get a list of displayable columns    *    * @return array,
    keys are printable column headers and values are SQL column names<br>
    */   function &amp;columns() {
        // return by reference
        $columns = array(
          ts('Contact Id') => 'contact_id',
          ts('Contact Type') => 'contact_type',
          ts('Name') => 'sort_name',
          ts('State') => 'state_province',
        );
        return $columns;   }</p>
    
    <p>/**    * Construct a full SQL query which returns one page worth of
    results    *    * @param int $offset    * @param int $rowcount    *
    @param null $sort    * @param bool $includeContactIDs    * @param bool
    $justIDs    * @return string, sql    */   function all($offset = 0,
    $rowcount = 0, $sort = NULL, $includeContactIDs = FALSE, $justIDs =
    FALSE) {
        // delegate to $this->sql(), $this->select(), $this->from(), $this->where(), etc.
        return $this->sql($this->select(), $offset, $rowcount, $sort, $includeContactIDs, NULL);   }</p>
    
    <p>/**    * Construct a SQL SELECT clause    *    * @return string, sql
    fragment with SELECT arguments    */   function select() {
        return "
          contact_a.id           as contact_id  ,
          contact_a.contact_type as contact_type,
          contact_a.sort_name    as sort_name,
          state_province.name    as state_province
        ";   }</p>
    
    <p>/**    * Construct a SQL FROM clause    *    * @return string, sql
    fragment with FROM and JOIN clauses    */   function from() {
        return "
          FROM      civicrm_contact contact_a
          LEFT JOIN civicrm_address address ON ( address.contact_id       = contact_a.id AND
                                                 address.is_primary       = 1 )
          LEFT JOIN civicrm_email           ON ( civicrm_email.contact_id = contact_a.id AND
                                                 civicrm_email.is_primary = 1 )
          LEFT JOIN civicrm_state_province state_province ON state_province.id = address.state_province_id
        ";   }</p>
    
    <p>/**    * Construct a SQL WHERE clause    *    * @param bool
    $includeContactIDs    * @return string, sql fragment with conditional
    expressions    */   function where($includeContactIDs = FALSE) {
        $params = array();
        $where = "contact_a.contact_type   = 'Household'";</p>
  
  <pre><code>$count  = 1;
  $clause = array();
  $name   = CRM_Utils_Array::value('household_name',
    $this-&gt;_formValues
  );
  if ($name != NULL) {
    if (strpos($name, '%') === FALSE) {
      $name = "%{$name}%";
    }
    $params[$count] = array($name, 'String');
    $clause[] = "contact_a.household_name LIKE %{$count}";
    $count++;
  }
  
  $state = CRM_Utils_Array::value('state_province_id',
    $this-&gt;_formValues
  );
  if (!$state &amp;&amp;
    $this-&gt;_stateID
  ) {
    $state = $this-&gt;_stateID;
  }
  
  if ($state) {
    $params[$count] = array($state, 'Integer');
    $clause[] = "state_province.id = %{$count}";
  }
  
  if (!empty($clause)) {
    $where .= ' AND ' . implode(' AND ', $clause);
  }
  
  return $this-&gt;whereClause($where, $params);   }
  </code></pre>
    
    <p>/**    * Determine the Smarty template for the search screen    *<br>
    * @return string, template path (findable through Smarty template path)    */   function templateFile() {
        return 'CRM/Contact/Form/Search/Custom.tpl';   }</p>
    
    <p>/**    * Modify the content of each row    *    * @param array $row
    modifiable SQL result row    * @return void    */   function
    alterRow(&amp;$row) {
        $row['sort_name'] .= ' ( altered )';   } }`</p>
  </blockquote>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-24T18:27:57.420Z
Answers.LastActivityDate: 2016-08-24T18:27:57.420Z
Answers.UserDisplayName: Sarah Poger Gladstone
Body: <p>I have a custom search extension and it was working fine in 4.4.14.
  Since I have upgraded to 4.6.3, "Actions" items only enabled for All records. But if I select certain records from result it does not enable "Actions" items. My custom PHP &amp; a screenshot is shown below.</p>
  
  <pre><code>    &lt;?php
  
  /**
   * A custom contact search
   */
  class CRM_Guestsearch_Form_Search_Guestsearch extends CRM_Contact_Form_Search_Custom_Base implements CRM_Contact_Form_Search_Interface {
  
    function __construct(&amp;$formValues) {
      parent::__construct($formValues);
    }
  
    /**
     * Prepare a set of search fields
     *
     * @param CRM_Core_Form $form modifiable
     * @return void
     */
    function buildForm(&amp;$form) {
      CRM_Utils_System::setTitle(ts('Registered Guest (Unassigned)'));
  
    /**
      $form-&gt;add('text', 'name', ts('Name'), TRUE
      );
  
      $form-&gt;setDefaults(array(
        'name' =&gt; '',
      ));
       */
      /**
       * if you are using the standard template, this array tells the template what elements
       * are part of the search criteria
       */
      $form-&gt;assign('elements', array('name'));
    }
  
    /**
     * Get a list of summary data points
     *
     * @return mixed; NULL or array with keys:
     *  - summary: string
     *  - total: numeric
     */
    function summary() {
      return NULL;
      // return array(
      //   'summary' =&gt; 'This is a summary',
      //   'total' =&gt; 50.0,
      // );
    }
  
    /**
     * Get a list of displayable columns
     *
     * @return array, keys are printable column headers and values are SQL column names
     */
    function &amp;columns() {
      // return by reference
      $columns = array(
        ts('Contact Source') =&gt; 'source',
        ts('Name') =&gt; 'sort_name',
        ts('Phone') =&gt; 'phone',
        ts('Email') =&gt; 'email',
        ts('Date of visit') =&gt; CIVICRM_GUESTSEARCH_CUSTOM_COLUMN_NAME,
      );
      return $columns;
    }
  
    /**
     * Construct a full SQL query which returns one page worth of results
     *
     * @param int $offset
     * @param int $rowcount
     * @param null $sort
     * @param bool $includeContactIDs
     * @param bool $justIDs
     * @return string, sql
     */
    function all($offset = 0, $rowcount = 0, $sort = NULL, $includeContactIDs = FALSE, $justIDs = FALSE) {
  
      return $this-&gt;sql($this-&gt;select(), $offset, $rowcount, null, $includeContactIDs, NULL);
    }
  
    /**
     * Construct a SQL SELECT clause
     *
     * @return string, sql fragment with SELECT arguments
     */
    function select() {
      return "
        contact_a.id                  as contact_id,
        contact_a.source              as source,
        contact_a.contact_sub_type    as contact_sub_type,
        contact_a.sort_name           as sort_name,
        phone.phone ,
        email.email  ,
        date.
      " . CIVICRM_GUESTSEARCH_CUSTOM_COLUMN_NAME;
    }
  
    /**
     * Construct a SQL FROM clause
     *
     * @return string, sql fragment with FROM and JOIN clauses
     */
    function from() {
      return "
        FROM      civicrm_contact contact_a
        LEFT JOIN civicrm_activity_contact a ON (a.contact_id = contact_a.id)
        LEFT JOIN civicrm_phone phone ON (phone.contact_id = contact_a.id)
        LEFT JOIN civicrm_email email ON (email.contact_id = contact_a.id)
        LEFT JOIN " . CIVICRM_GUESTSEARCH_CUSTOM_TABLE_NAME . " date ON (date.entity_id = contact_a.id)
      ";
    }
  
    /**
     * Construct a SQL WHERE clause
     *
     * @param bool $includeContactIDs
     * @return string, sql fragment with conditional expressions
     */
    function where($includeContactIDs = false) {
      $params = array();
  
      $where = "contact_a.contact_sub_type = 'Guest' AND contact_a.source = 'Guest Greeter Signup' AND activity_id IS NULL ORDER BY date." . CIVICRM_GUESTSEARCH_CUSTOM_COLUMN_NAME . " ASC ";
  
      return $where;
  
    }
  
    /**
     * Determine the Smarty template for the search screen
     *
     * @return string, template path (findable through Smarty template path)
     */
    function templateFile() {
      return 'CRM/Contact/Form/Search/Custom.tpl';
    }
  
    /**
     * Modify the content of each row
     *
     * @param array $row modifiable SQL result row
     * @return void
     */
  
  }
  </code></pre>
  
  <p><img src="https://i.sstatic.net/BzatC.png" alt="enter image description here"></p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-05-29T11:51:11.337Z
Comments.Text: Have you reviewed the wiki to see if there is any documentation on changes for searches from 4.4 to 4.6?
Comments.UserDisplayName: Joe Murray
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-05-29T14:19:54.453Z
Comments.Text: I did, but cant seems to find any significant difference..!!!
Comments.UserDisplayName: Tapash
Tags: <custom-search>
Title: Why doesn't custom search enable "Actions" items for selected records after upgrade to 4.6.3?
ThreadText: # Why doesn't custom search enable "Actions" items for selected records after upgrade to 4.6.3?
  
  (Asked by: username_0 on 2015-05-29)
  
  I have a custom search extension and it was working fine in 4.4.14.
  Since I have upgraded to 4.6.3, "Actions" items only enabled for All records. But if I select certain records from result it does not enable "Actions" items. My custom PHP & a screenshot is shown below.
  
  ```
      <?php
  
  /**
   * A custom contact search
   */
  class CRM_Guestsearch_Form_Search_Guestsearch extends CRM_Contact_Form_Search_Custom_Base implements CRM_Contact_Form_Search_Interface {
  
    function __construct(&$formValues) {
      parent::__construct($formValues);
    }
  
    /**
     * Prepare a set of search fields
     *
     * @param CRM_Core_Form $form modifiable
     * @return void
     */
    function buildForm(&$form) {
      CRM_Utils_System::setTitle(ts('Registered Guest (Unassigned)'));
  
    /**
      $form->add('text', 'name', ts('Name'), TRUE
      );
  
      $form->setDefaults(array(
        'name' => '',
      ));
       */
      /**
       * if you are using the standard template, this array tells the template what elements
       * are part of the search criteria
       */
      $form->assign('elements', array('name'));
    }
  
    /**
     * Get a list of summary data points
     *
     * @return mixed; NULL or array with keys:
     *  - summary: string
     *  - total: numeric
     */
    function summary() {
      return NULL;
      // return array(
      //   'summary' => 'This is a summary',
      //   'total' => 50.0,
      // );
    }
  
    /**
     * Get a list of displayable columns
     *
     * @return array, keys are printable column headers and values are SQL column names
     */
    function &columns() {
      // return by reference
      $columns = array(
        ts('Contact Source') => 'source',
        ts('Name') => 'sort_name',
        ts('Phone') => 'phone',
        ts('Email') => 'email',
        ts('Date of visit') => CIVICRM_GUESTSEARCH_CUSTOM_COLUMN_NAME,
      );
      return $columns;
    }
  
    /**
     * Construct a full SQL query which returns one page worth of results
     *
     * @param int $offset
     * @param int $rowcount
     * @param null $sort
     * @param bool $includeContactIDs
     * @param bool $justIDs
     * @return string, sql
     */
    function all($offset = 0, $rowcount = 0, $sort = NULL, $includeContactIDs = FALSE, $justIDs = FALSE) {
  
      return $this->sql($this->select(), $offset, $rowcount, null, $includeContactIDs, NULL);
    }
  
    /**
     * Construct a SQL SELECT clause
     *
     * @return string, sql fragment with SELECT arguments
     */
    function select() {
      return "
        contact_a.id                  as contact_id,
        contact_a.source              as source,
        contact_a.contact_sub_type    as contact_sub_type,
        contact_a.sort_name           as sort_name,
        phone.phone ,
        email.email  ,
        date.
      " . CIVICRM_GUESTSEARCH_CUSTOM_COLUMN_NAME;
    }
  
    /**
     * Construct a SQL FROM clause
     *
     * @return string, sql fragment with FROM and JOIN clauses
     */
    function from() {
      return "
        FROM      civicrm_contact contact_a
        LEFT JOIN civicrm_activity_contact a ON (a.contact_id = contact_a.id)
        LEFT JOIN civicrm_phone phone ON (phone.contact_id = contact_a.id)
        LEFT JOIN civicrm_email email ON (email.contact_id = contact_a.id)
        LEFT JOIN " . CIVICRM_GUESTSEARCH_CUSTOM_TABLE_NAME . " date ON (date.entity_id = contact_a.id)
      ";
    }
  
    /**
     * Construct a SQL WHERE clause
     *
     * @param bool $includeContactIDs
     * @return string, sql fragment with conditional expressions
     */
    function where($includeContactIDs = false) {
      $params = array();
  
      $where = "contact_a.contact_sub_type = 'Guest' AND contact_a.source = 'Guest Greeter Signup' AND activity_id IS NULL ORDER BY date." . CIVICRM_GUESTSEARCH_CUSTOM_COLUMN_NAME . " ASC ";
  
      return $where;
  
    }
  
    /**
     * Determine the Smarty template for the search screen
     *
     * @return string, template path (findable through Smarty template path)
     */
    function templateFile() {
      return 'CRM/Contact/Form/Search/Custom.tpl';
    }
  
    /**
     * Modify the content of each row
     *
     * @param array $row modifiable SQL result row
     * @return void
     */
  
  }
  
  ```
  
  ![enter image description here](https://i.sstatic.net/BzatC.png)
  
  **Tags:** custom-search
  
  > **Comments:**
  > **username_1**: Have you reviewed the wiki to see if there is any documentation on changes for searches from 4.4 to 4.6?  
  > **username_0**: I did, but cant seems to find any significant difference..!!!  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_2 on 2015-05-29. Score: 3
  
  Since the number of selected records hasn't updated when you check the box, that suggests it's possibly a Javascript error. Try the steps in [Troubleshooting JavaScript in CiviCRM](http://forum.civicrm.org/index.php/topic,35850) and post back any new diagnostic info you find.
  
  > **Comments:**
  > **username_0**: I have ran diagnostics and reported in this thread. Because this was happening all search function not only in custom search. http://civicrm.stackexchange.com/questions/3727/javascript-prevents-search-function-selecting-result-not-enabling-action-men  
  
  ---
  
  ### Answer by username_3 on 2021-03-28. Score: 2
  
  In 2021 is the same problem. In custom search you can't enable actions. But I find solution. I looked to the js file which count checkboxes and I found out that you just need remove "crm-ajax-selection-form" class from your search form. You can add to your tpl file somethink like this:
  `<script> {literal} CRM.$(".crm-ajax-selection-form").removeClass("crm-ajax-selection-form"); {/literal} </script>`
  2 hours reverse engineering was worth it. :D
  
  
  ---
  
  ### Answer by username_4 on 2016-08-24. Score: 0
  
  I am running into exactly the same problem (ie selecting some records does not activate the "Actions" button. It is happening with a custom search that was generated by "civix". (I only changed the title)
  
  Did anyone find a solution?
  
  Source code is: `
  
  > /\*\* \* A custom contact search \*/ class
  > CRM\_Financialsummaries\_Form\_Search\_preparestatements extends
  > CRM\_Contact\_Form\_Search\_Custom\_Base implements
  > CRM\_Contact\_Form\_Search\_Interface { function
  > \_\_construct(&$formValues) {
  > parent::\_\_construct($formValues); }
  >
  > /\*\* \* Prepare a set of search fields \* \* @param
  > CRM\_Core\_Form $form modifiable \* @return void \*/ function
  > buildForm(&$form) {
  > CRM\_Utils\_System::setTitle(ts('Prepare Statements'));
  >
  > ```
  > $form->add('text',
  >   'household_name',
  >   ts('Household Name'),
  >   TRUE
  > );
  >
  > $stateProvince = array('' => ts('- any state/province -')) + CRM_Core_PseudoConstant::stateProvince();
  > $form->addElement('select', 'state_province_id', ts('State/Province'), $stateProvince);
  >
  > // Optionally define default search values
  > $form->setDefaults(array(
  >   'household_name' => '',
  >   'state_province_id' => NULL,
  > ));
  >
  > /**
  >  * if you are using the standard template, this array tells the template what elements
  >  * are part of the search criteria
  >  */
  > $form->assign('elements', array('household_name', 'state_province_id'));   }
  >
  > ```
  >
  > /\*\* \* Get a list of summary data points \* \* @return mixed;
  > NULL or array with keys: \* - summary: string \* - total:
  > numeric \*/ function summary() {
  > return NULL;
  > // return array(
  > // 'summary' => 'This is a summary',
  > // 'total' => 50.0,
  > // ); }
  >
  > /\*\* \* Get a list of displayable columns \* \* @return array,
  > keys are printable column headers and values are SQL column names  
  > \*/ function &columns() {
  > // return by reference
  > $columns = array(
  > ts('Contact Id') => 'contact\_id',
  > ts('Contact Type') => 'contact\_type',
  > ts('Name') => 'sort\_name',
  > ts('State') => 'state\_province',
  > );
  > return $columns; }
  >
  > /\*\* \* Construct a full SQL query which returns one page worth of
  > results \* \* @param int $offset \* @param int $rowcount \*
  > @param null $sort \* @param bool $includeContactIDs \* @param bool
  > $justIDs \* @return string, sql \*/ function all($offset = 0,
  > $rowcount = 0, $sort = NULL, $includeContactIDs = FALSE, $justIDs =
  > FALSE) {
  > // delegate to $this->sql(), $this->select(), $this->from(), $this->where(), etc.
  > return $this->sql($this->select(), $offset, $rowcount, $sort, $includeContactIDs, NULL); }
  >
  > /\*\* \* Construct a SQL SELECT clause \* \* @return string, sql
  > fragment with SELECT arguments \*/ function select() {
  > return "
  > contact\_a.id as contact\_id ,
  > contact\_a.contact\_type as contact\_type,
  > contact\_a.sort\_name as sort\_name,
  > state\_province.name as state\_province
  > "; }
  >
  > /\*\* \* Construct a SQL FROM clause \* \* @return string, sql
  > fragment with FROM and JOIN clauses \*/ function from() {
  > return "
  > FROM civicrm\_contact contact\_a
  > LEFT JOIN civicrm\_address address ON ( address.contact\_id = contact\_a.id AND
  > address.is\_primary = 1 )
  > LEFT JOIN civicrm\_email ON ( civicrm\_email.contact\_id = contact\_a.id AND
  > civicrm\_email.is\_primary = 1 )
  > LEFT JOIN civicrm\_state\_province state\_province ON state\_province.id = address.state\_province\_id
  > "; }
  >
  > /\*\* \* Construct a SQL WHERE clause \* \* @param bool
  > $includeContactIDs \* @return string, sql fragment with conditional
  > expressions \*/ function where($includeContactIDs = FALSE) {
  > $params = array();
  > $where = "contact\_a.contact\_type = 'Household'";
  >
  > ```
  > $count  = 1;
  > $clause = array();
  > $name   = CRM_Utils_Array::value('household_name',
  >   $this->_formValues
  > );
  > if ($name != NULL) {
  >   if (strpos($name, '%') === FALSE) {
  >     $name = "%{$name}%";
  >   }
  >   $params[$count] = array($name, 'String');
  >   $clause[] = "contact_a.household_name LIKE %{$count}";
  >   $count++;
  > }
  >
  > $state = CRM_Utils_Array::value('state_province_id',
  >   $this->_formValues
  > );
  > if (!$state &&
  >   $this->_stateID
  > ) {
  >   $state = $this->_stateID;
  > }
  >
  > if ($state) {
  >   $params[$count] = array($state, 'Integer');
  >   $clause[] = "state_province.id = %{$count}";
  > }
  >
  > if (!empty($clause)) {
  >   $where .= ' AND ' . implode(' AND ', $clause);
  > }
  >
  > return $this->whereClause($where, $params);   }
  >
  > ```
  >
  > /\*\* \* Determine the Smarty template for the search screen \*  
  > \* @return string, template path (findable through Smarty template path) \*/ function templateFile() {
  > return 'CRM/Contact/Form/Search/Custom.tpl'; }
  >
  > /\*\* \* Modify the content of each row \* \* @param array $row
  > modifiable SQL result row \* @return void \*/ function
  > alterRow(&$row) {
  > $row['sort\_name'] .= ' ( altered )'; } }`
  
  
  ---
  
  