Body: <p>I'm trying to use SearchKit to build a Summary report and a related Detail report.</p>
  <p>I'm having trouble creating the <strong>URL link</strong> on the Summary report that links over to the Detail report.</p>
  <p>For the sake of giving an example that can be replicated on dmaster (5.77), imagine I want my Summary report to tally the number of Individual-type contacts by Contact Subtype (Parent, Student, Staff) with a FormBuilder filter by Gender as shown below.</p>
  <p><strong>Desired Summary Report</strong>
  <a href="https://i.sstatic.net/A17rh8JT.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/A17rh8JT.png" alt="enter image description here" /></a></p>
  <p>Then I want to link the number of contacts in the Summary results table to the Detail report, which shows who those contacts are.</p>
  <p>The problem is that the SearchKit Link feature (see below) doesn't seem to allow multiple values to be passed in as URL parameters. In the example below, the URL parameter <code>gender_id</code> should be either &quot;1&quot; or &quot;2&quot; or &quot;1, 2&quot; depending on what the user chooses to filter by using the checkboxes at the top.</p>
  <p>This is the full URL for the Link in the screen below:</p>
  <pre><code>civicrm/mydetailreport#?gender_id=[GROUP_CONCAT_gender_id]
  </code></pre>
  <p><a href="https://i.sstatic.net/65R2qudB.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/65R2qudB.png" alt="enter image description here" /></a></p>
  <p>The Detail report would then list the contacts filtered by the same filters as the Summary report, with the <code>gender_id</code> passed in as a URL param.</p>
  <p>So the query is getting the right data (as shown below), but the SK table is truncating or somehow limiting the <code>(List) Gender</code> column to the first value, rather than outputting the full list of values in the URL.</p>
  <p><a href="https://i.sstatic.net/Knrrjn6G.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Knrrjn6G.png" alt="enter image description here" /></a></p>
  <p>In the Summary report shown below, the URL link on the number <strong>57</strong> for the <code>Student</code> subtype should be...</p>
  <pre><code>https://dmaster.demo.civicrm.org/civicrm/mydetailreport#?gender_id=1,2
  </code></pre>
  <p>...but is actually:</p>
  <pre><code>https://dmaster.demo.civicrm.org/civicrm/mydetailreport#?gender_id=1
  </code></pre>
  <p><a href="https://i.sstatic.net/82pYnzLT.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/82pYnzLT.png" alt="enter image description here" /></a></p>
  <p>For reference, here's the exported SK:</p>
  <pre><code>[
    [
      &quot;SavedSearch&quot;,
      &quot;save&quot;,
      {
        &quot;records&quot;: [
          {
            &quot;name&quot;: &quot;Contacts_by_Type_and_Gender&quot;,
            &quot;label&quot;: &quot;Contacts by Individual Subtype and Gender&quot;,
            &quot;api_entity&quot;: &quot;Contact&quot;,
            &quot;api_params&quot;: {
              &quot;version&quot;: 4,
              &quot;select&quot;: [
                &quot;COUNT(id) AS COUNT_id&quot;,
                &quot;contact_sub_type:label&quot;,
                &quot;GROUP_CONCAT(DISTINCT gender_id) AS GROUP_CONCAT_gender_id&quot;
              ],
              &quot;orderBy&quot;: [],
              &quot;where&quot;: [
                [
                  &quot;contact_type:name&quot;,
                  &quot;=&quot;,
                  &quot;Individual&quot;
                ],
                [
                  &quot;contact_sub_type:name&quot;,
                  &quot;IS NOT EMPTY&quot;
                ],
                [
                  &quot;gender_id:name&quot;,
                  &quot;IS NOT EMPTY&quot;
                ]
              ],
              &quot;groupBy&quot;: [
                &quot;contact_sub_type&quot;
              ],
              &quot;join&quot;: [],
              &quot;having&quot;: []
            }
          }
        ],
        &quot;match&quot;: [
          &quot;name&quot;
        ]
      }
    ],
    [
      &quot;SearchDisplay&quot;,
      &quot;save&quot;,
      {
        &quot;records&quot;: [
          {
            &quot;name&quot;: &quot;Contacts_by_Type_and_Gender_Table_1&quot;,
            &quot;label&quot;: &quot;Contacts by Subtype Table 1&quot;,
            &quot;saved_search_id.name&quot;: &quot;Contacts_by_Type_and_Gender&quot;,
            &quot;type&quot;: &quot;table&quot;,
            &quot;settings&quot;: {
              &quot;description&quot;: null,
              &quot;sort&quot;: [
                [
                  &quot;COUNT_id&quot;,
                  &quot;DESC&quot;
                ]
              ],
              &quot;limit&quot;: 50,
              &quot;pager&quot;: [],
              &quot;placeholder&quot;: 5,
              &quot;columns&quot;: [
                {
                  &quot;type&quot;: &quot;field&quot;,
                  &quot;key&quot;: &quot;COUNT_id&quot;,
                  &quot;dataType&quot;: &quot;Integer&quot;,
                  &quot;label&quot;: &quot;(Count) Contact ID&quot;,
                  &quot;sortable&quot;: true,
                  &quot;link&quot;: {
                    &quot;path&quot;: &quot;civicrm/mydetailreport#?gender_id=[GROUP_CONCAT_gender_id]&quot;,
                    &quot;entity&quot;: &quot;&quot;,
                    &quot;action&quot;: &quot;&quot;,
                    &quot;join&quot;: &quot;&quot;,
                    &quot;target&quot;: &quot;_blank&quot;
                  }
                },
                {
                  &quot;type&quot;: &quot;field&quot;,
                  &quot;key&quot;: &quot;contact_sub_type:label&quot;,
                  &quot;dataType&quot;: &quot;String&quot;,
                  &quot;label&quot;: &quot;Contact Subtype&quot;,
                  &quot;sortable&quot;: true
                }
              ],
              &quot;actions&quot;: true,
              &quot;classes&quot;: [
                &quot;table&quot;,
                &quot;table-striped&quot;
              ]
            }
          }
        ],
        &quot;match&quot;: [
          &quot;saved_search_id&quot;,
          &quot;name&quot;
        ]
      }
    ],
    [
      &quot;Afform&quot;,
      &quot;save&quot;,
      {
        &quot;records&quot;: [
          {
            &quot;type&quot;: &quot;search&quot;,
            &quot;requires&quot;: null,
            &quot;entity_type&quot;: null,
            &quot;join_entity&quot;: null,
            &quot;title&quot;: &quot;My Summary Report by Subtype&quot;,
            &quot;description&quot;: null,
            &quot;placement&quot;: [],
            &quot;summary_contact_type&quot;: null,
            &quot;summary_weight&quot;: null,
            &quot;icon&quot;: &quot;fa-list-alt&quot;,
            &quot;server_route&quot;: &quot;civicrm/mysummaryreport&quot;,
            &quot;is_public&quot;: false,
            &quot;permission&quot;: [
              &quot;access CiviCRM&quot;
            ],
            &quot;permission_operator&quot;: &quot;AND&quot;,
            &quot;redirect&quot;: null,
            &quot;submit_enabled&quot;: true,
            &quot;submit_limit&quot;: null,
            &quot;create_submission&quot;: false,
            &quot;manual_processing&quot;: false,
            &quot;allow_verification_by_email&quot;: false,
            &quot;email_confirmation_template_id&quot;: null,
            &quot;navigation&quot;: null,
            &quot;modified_date&quot;: &quot;2024-07-23 17:09:03&quot;,
            &quot;layout&quot;: &quot;&lt;div af-fieldset=\&quot;\&quot;&gt;\n  &lt;af-field name=\&quot;gender_id\&quot; defn=\&quot;{input_type: 'CheckBox', input_attrs: {}, options: [{id: 1, label: 'Female'}, {id: 2, label: 'Male'}], afform_default: ['1', '2']}\&quot; /&gt;\n  &lt;af-field name=\&quot;GROUP_CONCAT_gender_id\&quot; defn=\&quot;{input_attrs: {multiple: true}}\&quot; /&gt;\n  &lt;crm-search-display-table search-name=\&quot;Contacts_by_Type_and_Gender\&quot; display-name=\&quot;Contacts_by_Type_and_Gender_Table_1\&quot;&gt;&lt;/crm-search-display-table&gt;\n&lt;/div&gt;\n&quot;,
            &quot;name&quot;: &quot;afsearchSummaryReportOfContactsByTypeAndGender&quot;
          }
        ]
      }
    ]
  ]
  </code></pre>
  <p><strong>Is it possible then to output a list of values as a URL param in the SK link?</strong></p>
  <p>I appreciate any ideas!</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-07-23T18:48:48.740Z
Comments.Text: My issue may be related to [question 44750](https://civicrm.stackexchange.com/questions/44750/why-are-searchkit-links-blank-if-a-data-item-is-missing) and the referenced [`replaceTokens()`](https://github.com/civicrm/civicrm-core/blob/ab1b5552cac8541178445fb36189a0a3820e1e51/ext/search_kit/Civi/Api4/Action/SearchDisplay/AbstractRunAction.php#L1133) function in Search Displays. Core devs, any thoughts?
Comments.UserDisplayName: Justin657
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-07-24T04:50:27.103Z
Comments.Text: did you spot the issue linked to that other ticket?
Comments.UserDisplayName: petednz - fuzion
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-07-24T15:00:59.243Z
Comments.Text: That other issue (which is still open) is related to null values as tokens. My issue is related to lists of values as tokens. Both seem to be related to code that sanitizes tokens for URLs.
Comments.UserDisplayName: Justin657
Tags: <searchkit>
Title: SearchKit: How to build a URL link with multi-value parameters
ThreadText: # SearchKit: How to build a URL link with multi-value parameters
  
  (Asked by: username_0 on 2024-07-23)
  
  I'm trying to use SearchKit to build a Summary report and a related Detail report.
  I'm having trouble creating the URL link on the Summary report that links over to the Detail report.
  For the sake of giving an example that can be replicated on dmaster (5.77), imagine I want my Summary report to tally the number of Individual-type contacts by Contact Subtype (Parent, Student, Staff) with a FormBuilder filter by Gender as shown below.
  Desired Summary Report
  
  Then I want to link the number of contacts in the Summary results table to the Detail report, which shows who those contacts are.
  The problem is that the SearchKit Link feature (see below) doesn't seem to allow multiple values to be passed in as URL parameters. In the example below, the URL parameter gender_id should be either "1" or "2" or "1, 2" depending on what the user chooses to filter by using the checkboxes at the top.
  This is the full URL for the Link in the screen below:
  civicrm/mydetailreport#?gender_id=[GROUP_CONCAT_gender_id]
  
  
  The Detail report would then list the contacts filtered by the same filters as the Summary report, with the gender_id passed in as a URL param.
  So the query is getting the right data (as shown below), but the SK table is truncating or somehow limiting the (List) Gender column to the first value, rather than outputting the full list of values in the URL.
  
  In the Summary report shown below, the URL link on the number 57 for the Student subtype should be...
  https://dmaster.demo.civicrm.org/civicrm/mydetailreport#?gender_id=1,2
  
  ...but is actually:
  https://dmaster.demo.civicrm.org/civicrm/mydetailreport#?gender_id=1
  
  
  For reference, here's the exported SK:
  [
    [
      "SavedSearch",
      "save",
      {
        "records": [
          {
            "name": "Contacts_by_Type_and_Gender",
            "label": "Contacts by Individual Subtype and Gender",
            "api_entity": "Contact",
            "api_params": {
              "version": 4,
              "select": [
                "COUNT(id) AS COUNT_id",
                "contact_sub_type:label",
                "GROUP_CONCAT(DISTINCT gender_id) AS GROUP_CONCAT_gender_id"
              ],
              "orderBy": [],
              "where": [
                [
                  "contact_type:name",
                  "=",
                  "Individual"
                ],
                [
                  "contact_sub_type:name",
                  "IS NOT EMPTY"
                ],
                [
                  "gender_id:name",
                  "IS NOT EMPTY"
                ]
              ],
              "groupBy": [
                "contact_sub_type"
              ],
              "join": [],
              "having": []
            }
          }
        ],
        "match": [
          "name"
        ]
      }
    ],
    [
      "SearchDisplay",
      "save",
      {
        "records": [
          {
            "name": "Contacts_by_Type_and_Gender_Table_1",
            "label": "Contacts by Subtype Table 1",
            "saved_search_id.name": "Contacts_by_Type_and_Gender",
            "type": "table",
            "settings": {
              "description": null,
              "sort": [
                [
                  "COUNT_id",
                  "DESC"
                ]
              ],
              "limit": 50,
              "pager": [],
              "placeholder": 5,
              "columns": [
                {
                  "type": "field",
                  "key": "COUNT_id",
                  "dataType": "Integer",
                  "label": "(Count) Contact ID",
                  "sortable": true,
                  "link": {
                    "path": "civicrm/mydetailreport#?gender_id=[GROUP_CONCAT_gender_id]",
                    "entity": "",
                    "action": "",
                    "join": "",
                    "target": "_blank"
                  }
                },
                {
                  "type": "field",
                  "key": "contact_sub_type:label",
                  "dataType": "String",
                  "label": "Contact Subtype",
                  "sortable": true
                }
              ],
              "actions": true,
              "classes": [
                "table",
                "table-striped"
              ]
            }
          }
        ],
        "match": [
          "saved_search_id",
          "name"
        ]
      }
    ],
    [
      "Afform",
      "save",
      {
        "records": [
          {
            "type": "search",
            "requires": null,
            "entity_type": null,
            "join_entity": null,
            "title": "My Summary Report by Subtype",
            "description": null,
            "placement": [],
            "summary_contact_type": null,
            "summary_weight": null,
            "icon": "fa-list-alt",
            "server_route": "civicrm/mysummaryreport",
            "is_public": false,
            "permission": [
              "access CiviCRM"
            ],
            "permission_operator": "AND",
            "redirect": null,
            "submit_enabled": true,
            "submit_limit": null,
            "create_submission": false,
            "manual_processing": false,
            "allow_verification_by_email": false,
            "email_confirmation_template_id": null,
            "navigation": null,
            "modified_date": "2024-07-23 17:09:03",
            "layout": "\n  \n  \n  \n\n",
            "name": "afsearchSummaryReportOfContactsByTypeAndGender"
          }
        ]
      }
    ]
  ]
  
  Is it possible then to output a list of values as a URL param in the SK link?
  I appreciate any ideas!
  
  **Tags:** searchkit
  
  > **Comments:**
  > **username_0**: My issue may be related to [question 44750](https://civicrm.stackexchange.com/questions/44750/why-are-searchkit-links-blank-if-a-data-item-is-missing) and the referenced [`replaceTokens()`](https://github.com/civicrm/civicrm-core/blob/ab1b5552cac8541178445fb36189a0a3820e1e51/ext/search_kit/Civi/Api4/Action/SearchDisplay/AbstractRunAction.php#L1133) function in Search Displays. Core devs, any thoughts?  
  > **username_1**: did you spot the issue linked to that other ticket?  
  > **username_0**: That other issue (which is still open) is related to null values as tokens. My issue is related to lists of values as tokens. Both seem to be related to code that sanitizes tokens for URLs.  
  
  ---
  
  ## 0 answers
  
  