Skip to content

Cannot Save Business Address as Former Address More Than Once #6929

Description

@LaceyGilliam

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)

  1. 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.
  2. Workflow action (Rock/Workflow/Action/Finance/BusinessFromAttributes.cs:270) has the identical misuse and same crash.
  3. 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.

Image

Expected Behavior

Expected Behavior

It should be possible to create more than one previous address.

Steps to Reproduce

  1. Create a new business record with an address.
Image
  1. Edit the business and change the address, checking the “Save Former Address As Previous Address” checkbox.
Image
  1. Note that no previous address list is shown as it was on the webforms block.

  2. 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

  • 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

At least v19.1 through prealpha 20.0.5 ( Any version using the obsidian business detail block. )

Client Culture Setting

EN-US

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions