webform_civicrm
webform_civicrm copied to clipboard
D8/9 - Fix case update when client != c1
Overview
Fix case update when client != c1.
Before
Case updated on c1 when client is set to c2. To replicate -
- Create a webform with 2 contacts.
- Case tab - Select 1 in the Number of case with Case client = Contact 2.
- Ensure
Update Existing Case
is set to Ongoing. - Set the widget of Contact 2 to autocomplete.
- Load the webform and submit. Confirm a case is created on contact 2.
- Load the webform again and submit with same set of contacts.
Expected Result: Case on contact 2 should be updated.
Actual Result: New Case is created on contact 2.
After
Fixed. Existing case on the contact is updated.
Technical Details
The previous variable - $this->ent['contact'][$n]['id']
has $n iterating as 1, 2, 3... which considers c1, c2 to check for existing case. This should instead be checking for client id set on the webform setting which correctly arrives on $data['case'][1]['client_id']
.
I felt bad about rejecting #647 so I tried testing this PR as well.
Unfortunately, there's a hard-coded assumption that the manager is contact B in a relationship.
This is out of scope for this PR, but is a blocker to my testing.