Answers.Body: <p>I think the <a href="https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_apiWrappers/" rel="nofollow noreferrer">apiWrapper hook</a> can do this (it's deprecated, but scroll down to see how to implement it the new way)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-04-26T14:27:55.790Z
Answers.LastActivityDate: 2023-04-26T14:27:55.790Z
Answers.UserDisplayName: Andrew West
Body: <p>We are building a search form using a search kit. Based on saved search name</p>
  <pre><code>    [
        [
          &quot;SearchDisplay&quot;,
          &quot;run&quot;,
          {
            &quot;return&quot;: &quot;page:1&quot;,
            &quot;savedSearch&quot;: &quot;Member_Player_Search&quot;,
            &quot;display&quot;: &quot;Table&quot;,
            &quot;sort&quot;: [
              [
                &quot;sort_name&quot;,
                &quot;ASC&quot;
              ]
            ],
            &quot;limit&quot;: 50,
            &quot;seed&quot;: 1682511192645,
            &quot;filters&quot;: {
              &quot;last_name&quot;: &quot;test&quot;,
              &quot;first_name&quot;: &quot;user&quot;
            },
            &quot;afform&quot;: &quot;afsearchPlayerSearch&quot;
          }
        ]
      ]
  </code></pre>
  <p>Example :</p>
  <pre><code>if (!empty($filter['last_name'])) {
    $filter['custom_123'] = 1;
  }
  // custom_123 is boolean field of Yes/No.
  </code></pre>
  <p>If the last name is not empty in the filter then I want to add an additional filter before making a call to contact api. (through hook)</p>
  <p>Is this feasible ?</p>
  <p>I tried using the search kit tool <strong>fx</strong> <code>if/else</code> functionality but was not able to figure it out in the UI to make the same condition.</p>
  <p>Drupal 9, CiviCRM 5.57</p>
  
Tags: <searchkit><search-builder>
Title: I there way to intercept the API4 call made for SearchDisplay run
ThreadText: # I there way to intercept the API4 call made for SearchDisplay run
  
  (Asked by: username_0 on 2023-04-26)
  
  We are building a search form using a search kit. Based on saved search name
  
  ```
      [
        [
          "SearchDisplay",
          "run",
          {
            "return": "page:1",
            "savedSearch": "Member_Player_Search",
            "display": "Table",
            "sort": [
              [
                "sort_name",
                "ASC"
              ]
            ],
            "limit": 50,
            "seed": 1682511192645,
            "filters": {
              "last_name": "test",
              "first_name": "user"
            },
            "afform": "afsearchPlayerSearch"
          }
        ]
      ]
  
  ```
  
  Example :
  
  ```
  if (!empty($filter['last_name'])) {
    $filter['custom_123'] = 1;
  }
  // custom_123 is boolean field of Yes/No.
  
  ```
  
  If the last name is not empty in the filter then I want to add an additional filter before making a call to contact api. (through hook)
  
  Is this feasible ?
  
  I tried using the search kit tool **fx** `if/else` functionality but was not able to figure it out in the UI to make the same condition.
  
  Drupal 9, CiviCRM 5.57
  
  **Tags:** searchkit, search-builder
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-04-26. Score: 1 | Accepted answer
  
  I think the [apiWrapper hook](https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_apiWrappers/) can do this (it's deprecated, but scroll down to see how to implement it the new way)
  
  
  ---
  
  