Question

Photo of Nathan Parikh

0

SOLUTION: Error when trying to merge people on 7.3

Putting this here for anyone else who has had this issue. Thanks to Daniel Hazelbaker for helping with this!

On Rock v7.3 We've merged people/records before many times without any issue. However, we started getting the following error when trying to merge:

Merge Error
The following error occurred when attempting the merge: Object reference not set to an instance of an object.

Checked out the system exceptions log and it returned the following:

Source: App_Web_axtjchf5

Stack Trace:

at RockWeb.Blocks.Crm.PersonMerge.<>c__DisplayClass27.b__14() in c:\inetpub\Rock\Blocks\Crm\PersonMerge.ascx.cs:line 608
at Rock.Data.DbContext.WrapTransaction(Action action)
at RockWeb.Blocks.Crm.PersonMerge.lbMerge_Click(Object sender, EventArgs e) in c:\inetpub\Rock\Blocks\Crm\PersonMerge.ascx.cs:line 360.

The error indicates that it loaded a Group that should have existed, but for whatever reasons didn't actually exist.
To check if this is actually the case, use the following SQL:

SELECT * FROM [GroupMember] AS GM LEFT JOIN [Group] AS G ON G.Id = GM.GroupId WHERE G.Id IS NULL

For us, this returned about 192 rows of affected data - people that were linked to non-existent group IDs.

To test removing these faulty rows, use the following SQL:

BEGIN TRANSACTION
DELETE GM FROM [GroupMember] AS GM LEFT JOIN [Group] AS G ON G.Id = GM.GroupId WHERE G.Id IS NULL
ROLLBACK TRANSACTION

For us, this also returned 192 rows so I was confident we had a match and were ready to actually remove this faulty data.
To actually remove the data, simply delete the two TRANSACTION lines:

DELETE GM FROM [GroupMember] AS GM LEFT JOIN [Group] AS G ON G.Id = GM.GroupId WHERE G.Id IS NULL

After running the delete statement, we were able to successfully merge people again.

  • Photo of Nathan Parikh

    0

    See above for my answer :)