Description
The ability to save a former address as a Previous Address for businesses does not function properly with the Obsidian Business Detail block. The option will work once on a business, but trying to save a former address as a previous address more than once fails due the creation of a duplicate key.
Recommended fix
The "previous addresses" display reads all history rows regardless of CurrentRowIndicator, and the index only guards current rows — so record the former address as a non-current row:
var formerAddress = GroupLocationHistorical.CreateCurrentRowFromGroupLocation( workLocation, RockDateTime.Now );
formerAddress.CurrentRowIndicator = false;
formerAddress.ExpireDateTime = RockDateTime.Now;
new GroupLocationHistoricalService( RockContext ).Add( formerAddress );
Never collides, works whether or not group-history tracking is enabled, and still displays as a previous address.
Related issues in the same code (worth fixing together)
- Clear-address branch (BusinessDetail.cs:812): when removing an address with the box checked, the created history row is discarded (never added) — silent no-op. That branch also deletes the GroupLocation, and the GroupLocationHistorical → GroupLocation FK is WillCascadeOnDelete(true), so a proper fix must detach the history row (null GroupLocationId) before delete.
- Workflow action (Rock/Workflow/Action/Finance/BusinessFromAttributes.cs:270) has the identical misuse and same crash.
- Display loop (BusinessDetail.cs:424-427): bag.PreviousAddress is overwritten each iteration, so only the last previous address shows (cosmetic).
Actual Behavior
Actual Behavior
Trying to save an address as previous will throw a duplicate key exception, if “Save Former Address As Previous Address” is checked and a previous address already exists.
Expected Behavior
Expected Behavior
It should be possible to create more than one previous address.
Steps to Reproduce
- Create a new business record with an address.
- Edit the business and change the address, checking the “Save Former Address As Previous Address” checkbox.
-
Note that no previous address list is shown as it was on the webforms block.
-
Modify the business address again, checking the “Save Former Address As Previous Address” again. It will not save, and throw the exception shown in the screenshot for Actual Behavior.
Issue Confirmation
Rock Version
At least v19.1 through prealpha 20.0.5 ( Any version using the obsidian business detail block. )
Client Culture Setting
EN-US
Description
The ability to save a former address as a Previous Address for businesses does not function properly with the Obsidian Business Detail block. The option will work once on a business, but trying to save a former address as a previous address more than once fails due the creation of a duplicate key.
Recommended fix
The "previous addresses" display reads all history rows regardless of CurrentRowIndicator, and the index only guards current rows — so record the former address as a non-current row:
Never collides, works whether or not group-history tracking is enabled, and still displays as a previous address.
Related issues in the same code (worth fixing together)
Actual Behavior
Actual Behavior
Trying to save an address as previous will throw a duplicate key exception, if “Save Former Address As Previous Address” is checked and a previous address already exists.
Expected Behavior
Expected Behavior
It should be possible to create more than one previous address.
Steps to Reproduce
Note that no previous address list is shown as it was on the webforms block.
Modify the business address again, checking the “Save Former Address As Previous Address” again. It will not save, and throw the exception shown in the screenshot for Actual Behavior.
Issue Confirmation
Rock Version
At least v19.1 through prealpha 20.0.5 ( Any version using the obsidian business detail block. )
Client Culture Setting
EN-US