2

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 enter image description here

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]

enter image description here

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.

enter image description here

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

enter image description here

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": "<div af-fieldset=\"\">\n  <af-field name=\"gender_id\" defn=\"{input_type: 'CheckBox', input_attrs: {}, options: [{id: 1, label: 'Female'}, {id: 2, label: 'Male'}], afform_default: ['1', '2']}\" />\n  <af-field name=\"GROUP_CONCAT_gender_id\" defn=\"{input_attrs: {multiple: true}}\" />\n  <crm-search-display-table search-name=\"Contacts_by_Type_and_Gender\" display-name=\"Contacts_by_Type_and_Gender_Table_1\"></crm-search-display-table>\n</div>\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!

3
  • My issue may be related to question 44750 and the referenced replaceTokens() function in Search Displays. Core devs, any thoughts?
    – Justin657
    Commented Jul 23 at 18:48
  • did you spot the issue linked to that other ticket?
    – petednz - fuzion
    Commented Jul 24 at 4:50
  • 1
    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.
    – Justin657
    Commented Jul 24 at 15:00

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.