Skip to content

Opportunity-level "Activity Added" connection workflows never fire (qualifier stored as Guid, matched as integer Id) #6986

Description

@karenn-ccbc

Description

A connection workflow with the Activity Added trigger type, configured at the Connection Opportunity level and scoped to a specific activity type, silently never launches when that activity is added to a request. No error is raised and nothing is logged. The identical trigger configured at the Connection Type level works correctly.

Root cause: The Obsidian Connection Opportunity Detail block stores the selected activity type in ConnectionWorkflow.QualifierValue as the activity type's Guid, but the runtime matcher expects the activity type's integer Id.

  • The activity-type dropdown options use the Guid as the value — Rock.Blocks/Engagement/ConnectionOpportunityDetail.cs (~line 1354):
    .Select( a => new ListItemBag { Text = a.Name, Value = a.Guid.ToString() } )  // Guid
  • On save, the block writes the qualifier verbatim with no Guid→Id conversion — ToDelimitedQualifierValue (~line 725), producing |<activityTypeGuid>||.
  • The runtime matcher parses that qualifier as an integer — Rock/Transactions/ConnectionRequestActivityChangeTransaction.cs:128 (QualifiersMatch):
    var qualifierGroupId = qualifierParts[1].AsIntegerOrNull();  // null for a Guid
    ...
    else { matches = false; }   // always taken → workflow never launches

The Connection Type Detail block does perform this conversion (ConvertPrimaryQualifierGuidToId, Rock.Blocks/Engagement/ConnectionTypeDetail.cs ~line 1146), which is why type-level triggers work. The opportunity block is missing the conversion on both read and save.

Scope of impact:

  • Opportunity-level Activity Added triggers scoped to a specific activity type: broken.
  • Type-level Activity Added triggers: work.
  • Opportunity-level triggers with a blank activity qualifier ("any activity"): work (blank qualifier leaves matches = true).
  • Triggers created by the legacy WebForms block that stored integer Ids: work until re-saved through the new opportunity block, which rewrites them to Guids.

Diagnostic query (broken rows show a Guid between the pipes; correct rows show an integer):

SELECT cw.Id, ct.Name AS ConnectionType, co.Name AS Opportunity,
       wt.Name AS WorkflowType, cw.QualifierValue
FROM ConnectionWorkflow cw
JOIN WorkflowType wt ON wt.Id = cw.WorkflowTypeId
LEFT JOIN ConnectionOpportunity co ON co.Id = cw.ConnectionOpportunityId
LEFT JOIN ConnectionType ct ON ct.Id = cw.ConnectionTypeId
WHERE cw.TriggerType = 4;   -- ActivityAdded

Suggested fix: Mirror the Connection Type Detail block's Guid↔Id conversion in ConnectionOpportunityDetail.cs for the ActivityAdded trigger type (Id→Guid when populating the editor, Guid→Id in ToDelimitedQualifierValue). A data-fix migration may be warranted to repair qualifiers already saved as Guids.

Actual Behavior

The workflow does not launch when the matching activity is added to a request. ConnectionWorkflow.QualifierValue contains a Guid (e.g. |a1b2c3d4-....||) instead of the activity type's integer Id, so the runtime match always fails. No error or log entry is produced.

Expected Behavior

When an activity of the configured type is added to a request in that opportunity, the associated workflow launches — the same as when the trigger is configured at the Connection Type level.

Steps to Reproduce

On a Connection Type, create at least one Connection Activity Type.

  • On a Connection Opportunity under that type, add a Connection Workflow with Trigger Type "Activity Added" and select a specific Activity Type (not blank). Save.
  • Open a connection request in that opportunity and add an activity of the selected type.
  • Observe that the workflow does not launch. (Check ConnectionWorkflow.QualifierValue — it holds a Guid instead of an integer Id.)

Issue Confirmation

  • Perform a search on the Github Issues to see if your bug is already reported.
  • Reproduced the problem on a fresh install or on the demo site.

Rock Version

19.2

Client Culture Setting

en-US

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions