Skip to content

Conversation

@uberbrady
Copy link
Member

As noted in #18160 you don't get the correct "serial number is invalid" message when you have a non-unique serial number while creating assets. In researching this, however, that led me down quite a rabbit hole where plenty of values weren't going to get correctly repopulated, especially on creating multiple items.

The behavior we had before was trying to create some of the items, if possible, giving a partial-success, partial-failure message. This changes the behavior so that if anything would fail, the entire submit is aborted and the fields are re-filled-out for you to make whatever changes you like (including, if you want, removing the item that can't be created). So either everything will succeed, or nothing will happen, and you get kicked back with the appropriate error messaging.

Much of the functionality is achieved with a new FormRequest that is multiple-submit-aware. But since some things can still slip through that - the database is, at the end, the ultimate arbiter - we also wrap the multiple-create step in a transaction, and rollback on any failures.

This meant I did have to create a new UniqueUndeleted validation rule, which can be used more easily in a FormRequest context.

Screenshots

Trying to specify the same (new) serial number twice

Screenshot 2025-11-25 at 7 44 35 PM

One valid asset tag, one that's already in the DB

Screenshot 2025-11-25 at 7 45 05 PM

Multiple values invalid, but one field is valid

Screenshot 2025-11-25 at 8 22 33 PM

Custom field with uniqueness constraint specified in multi-create

Screenshot 2025-11-25 at 8 28 06 PM

Fixes #18160

@uberbrady uberbrady requested a review from snipe as a code owner November 25, 2025 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant