twomice / com.joineryhq.campaigntools

Other
0 stars 2 forks source link

Error when selecting Activities tab on Contact record #5

Open mrinkel opened 4 months ago

mrinkel commented 4 months ago

I just installed this extension. The basic features tested ok, but now, when I go into a contact record and click on the Activities Tab, I get the following error and the tab doesn't load:

Network Error Unable to reach the server. Please refresh this page in your browser and try again.

When I disable the extension, the problem goes away. If I enable the extension, the problem returns.

I've selected No to showing Show campaign on Activities tab in Campaign Tools: Settings with no change.

Joinery Campaign Tools: Version 1.2 CiviCRM site is running version 5.74.4 on Wordpress

twomice commented 4 months ago

Thanks for the report @mrinkel .

FYI, I'm able to reproduced this in Drupal, so will continue there unless WP turns out to be especially relevant.

Fatal error (visible if opening the Activities tab in a new browser tab) is:

Error: Cannot access protected property CRM_Activity_Page_Tab::$_action in campaigntools_civicrm_pageRun() (line 16 of /home/as/_laptop/projects/com.joineryhq.campaigntools/campaigntools.php).

I suspect this is caused by the fact that CiviCRM's Activities tab is now using newer SearchKit-based displays, which this extension wasn't built to handle.

I see a couple of options here:

  1. Improve the extension so that the Campaign is displayed on the Activities tab (per the design of this extension), without this fatal error.
    • If you have access to developer resources (your own skills, or a developer of your preference) to conttibute a code patch / PR to make this work, I'm certainly open to adding that fix to the extension.
    • If you'd like me to do this as a paid project, we can discuss that too.
  2. Modify the extension so that it no longer attempts to display Campaign on the Activities tab. If you like that idea, let me know; it should be easy enough that I could do it as a community contribution (i.e., without a fee).

I'm sorry it's not "just working as it should" right out of the box. I hope one of the options above will help you get what you need from it.

mrinkel commented 4 months ago

Thank you for the quick response. Option 2 will work for me because I don't really need it on the activities tab anyways. If I get to the point where it would be nice to have on the activities tab, I can dig into the code and submit a fix (I just don't have time at this point).

Thank you! Mark

andyburnsco commented 1 month ago

Just my 2 cents on this. I'd suggest option 2 in the short-run as that's the core value behind the functionality IMO.

@mrinkel SK isn't yet active on the activities tab https://lab.civicrm.org/dev/core/-/issues/4950 but can be by following Coleman's answer here: https://civicrm.stackexchange.com/questions/47794/creating-a-search-kit-contact-summary-tab-for-activities-how-do-you-only-displa.

Note: depending on your db size and complexity, you may have to limit it to certain activities for it to function currently, which may be a feature depending on how you look at it ;)

image

You should be able to import this search configuration and it should update the existing. Uses a rewrite, you could instead just add the campaign column by itself in SK.

[
  [
    "SavedSearch",
    "save",
    {
      "records": [
        {
          "name": "Contact_Summary_Activities",
          "label": "Contact Summary Activities",
          "api_entity": "Activity",
          "api_params": {
            "version": 4,
            "select": [
              "activity_type_id:label",
              "subject",
              "activity_date_time",
              "status_id:label",
              "GROUP_CONCAT(UNIQUE Activity_ActivityContact_Contact_02.sort_name) AS GROUP_CONCAT_Activity_ActivityContact_Contact_02_sort_name",
              "GROUP_CONCAT(UNIQUE Activity_ActivityContact_Contact_03.sort_name) AS GROUP_CONCAT_Activity_ActivityContact_Contact_03_sort_name",
              "GROUP_CONCAT(UNIQUE Activity_ActivityContact_Contact_04.sort_name) AS GROUP_CONCAT_Activity_ActivityContact_Contact_04_sort_name",
              "campaign_id:label"
            ],
            "orderBy": [],
            "where": [],
            "groupBy": [
              "id"
            ],
            "join": [
              [
                "Contact AS Activity_ActivityContact_Contact_01",
                "INNER",
                "ActivityContact",
                [
                  "id",
                  "=",
                  "Activity_ActivityContact_Contact_01.activity_id"
                ]
              ],
              [
                "Contact AS Activity_ActivityContact_Contact_02",
                "LEFT",
                "ActivityContact",
                [
                  "id",
                  "=",
                  "Activity_ActivityContact_Contact_02.activity_id"
                ],
                [
                  "Activity_ActivityContact_Contact_02.record_type_id:name",
                  "=",
                  "\"Activity Source\""
                ]
              ],
              [
                "Contact AS Activity_ActivityContact_Contact_03",
                "LEFT",
                "ActivityContact",
                [
                  "id",
                  "=",
                  "Activity_ActivityContact_Contact_03.activity_id"
                ],
                [
                  "Activity_ActivityContact_Contact_03.record_type_id:name",
                  "=",
                  "\"Activity Targets\""
                ]
              ],
              [
                "Contact AS Activity_ActivityContact_Contact_04",
                "LEFT",
                "ActivityContact",
                [
                  "id",
                  "=",
                  "Activity_ActivityContact_Contact_04.activity_id"
                ],
                [
                  "Activity_ActivityContact_Contact_04.record_type_id:name",
                  "=",
                  "\"Activity Assignees\""
                ]
              ]
            ],
            "having": []
          }
        }
      ],
      "match": [
        "name"
      ]
    }
  ],
  [
    "SearchDisplay",
    "save",
    {
      "records": [
        {
          "name": "Contact_Summary_Activities_Tab",
          "label": "Contact Summary Activities Tab",
          "saved_search_id.name": "Contact_Summary_Activities",
          "type": "table",
          "settings": {
            "description": null,
            "sort": [
              [
                "activity_date_time",
                "DESC"
              ]
            ],
            "limit": 50,
            "pager": {
              "hide_single": true,
              "show_count": true,
              "expose_limit": true
            },
            "placeholder": 5,
            "columns": [
              {
                "type": "html",
                "key": "activity_type_id:label",
                "dataType": "Integer",
                "label": "Type",
                "sortable": true,
                "rewrite": "[activity_type_id:label] <br>\n<i>([campaign_id:label])</i>"
              },
              {
                "type": "field",
                "key": "subject",
                "dataType": "String",
                "label": "Subject",
                "sortable": true,
                "editable": true
              },
              {
                "type": "field",
                "key": "activity_date_time",
                "dataType": "Timestamp",
                "label": "Date",
                "sortable": true
              },
              {
                "type": "field",
                "key": "status_id:label",
                "dataType": "Integer",
                "label": "Status",
                "sortable": true,
                "editable": true
              },
              {
                "type": "field",
                "key": "GROUP_CONCAT_Activity_ActivityContact_Contact_02_sort_name",
                "dataType": "String",
                "label": "Added By",
                "sortable": true,
                "link": {
                  "entity": "Contact",
                  "action": "view",
                  "join": "Activity_ActivityContact_Contact_02",
                  "target": "_blank"
                }
              },
              {
                "type": "field",
                "key": "GROUP_CONCAT_Activity_ActivityContact_Contact_03_sort_name",
                "dataType": "String",
                "label": "With",
                "sortable": true,
                "link": {
                  "entity": "Contact",
                  "action": "view",
                  "join": "Activity_ActivityContact_Contact_03",
                  "target": "_blank"
                }
              },
              {
                "type": "field",
                "key": "GROUP_CONCAT_Activity_ActivityContact_Contact_04_sort_name",
                "dataType": "String",
                "label": "Assigned",
                "sortable": true,
                "link": {
                  "entity": "Contact",
                  "action": "view",
                  "join": "Activity_ActivityContact_Contact_04",
                  "target": "_blank"
                }
              },
              {
                "text": "",
                "style": "default",
                "size": "btn-xs",
                "icon": "fa-bars",
                "links": [
                  {
                    "entity": "Activity",
                    "action": "view",
                    "target": "crm-popup",
                    "icon": "fa-external-link",
                    "text": "View Activity",
                    "style": "default",
                    "path": "",
                    "task": "",
                    "join": "",
                    "condition": []
                  },
                  {
                    "entity": "Activity",
                    "action": "update",
                    "target": "crm-popup",
                    "icon": "fa-pencil",
                    "text": "Update Activity",
                    "style": "default",
                    "path": "",
                    "task": "",
                    "join": "",
                    "condition": []
                  },
                  {
                    "entity": "Activity",
                    "action": "delete",
                    "target": "crm-popup",
                    "icon": "fa-trash",
                    "text": "Delete Activity",
                    "style": "danger",
                    "path": "",
                    "task": "",
                    "join": "",
                    "condition": []
                  }
                ],
                "type": "menu",
                "alignment": "text-right"
              }
            ],
            "classes": [
              "table",
              "table-striped"
            ],
            "toolbar": [
              {
                "action": "add",
                "entity": "Activity",
                "text": "Add Activity",
                "icon": "fa-plus",
                "style": "primary",
                "target": "crm-popup",
                "path": "",
                "task": "",
                "join": "",
                "condition": []
              }
            ]
          }
        }
      ],
      "match": [
        "saved_search_id",
        "name"
      ]
    }
  ],
  [
    "Afform",
    "save",
    {
      "records": [
        {
          "type": "search",
          "requires": null,
          "entity_type": null,
          "join_entity": null,
          "title": "Activities",
          "description": "",
          "placement": [
            "contact_summary_tab"
          ],
          "summary_contact_type": null,
          "summary_weight": 70,
          "icon": "fa-tasks",
          "server_route": "",
          "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-10-06 17:17:10",
          "layout": "<div af-fieldset=\"\" store-values=\"1\">\n  <div class=\"af-container af-layout-inline\">\n    <af-field name=\"activity_type_id\" defn=\"{input_attrs: {multiple: true, placeholder: 'Include'}, label: false, search_operator: 'IN'}\" />\n    <af-field name=\"activity_type_id\" defn=\"{input_attrs: {multiple: true, placeholder: 'Exclude'}, label: false, search_operator: 'NOT IN'}\" />\n    <af-field name=\"status_id\" defn=\"{input_attrs: {multiple: true, placeholder: 'Status'}, label: false}\" />\n    <af-field name=\"activity_date_time\" defn=\"{input_type: 'Select', search_range: true, input_attrs: {placeholder: 'Date'}, label: false}\" />\n  </div>\n  <crm-search-display-table search-name=\"Contact_Summary_Activities\" display-name=\"Contact_Summary_Activities_Tab\" filters=\"{'source_contact_id': options.contact_id}\"></crm-search-display-table>\n</div>\n",
          "name": "afsearchTabActivity"
        }
      ]
    }
  ]
]