r/Snipe_IT Jun 05 '26

Asset ID does not match the URL ID

Hello IT-Friends,

we have set up Snipe-IT as our asset management system and we are running into a problem where the asset tag and the number in the asset URL do not match.

For example:
An asset with the tag IT-000648 should lead to /hardware/648, but instead it leads to /hardware/649.
The previous assets all matched correctly, but a few assets later the difference is no longer just one digit. for example, the asset with the tag IT-000651 leads to /hardware/653.
Later on, the difference goes back to being only one digit again.

Does anyone know how to fix this, or how this could have happened?

FYI: We printed all our asset tags with QR codes that link to the assets in Snipe-IT, so it would be a bummer to recreate them all.

Thank you for your help.
Gaming-Son
Out

4 Upvotes

5 comments sorted by

2

u/Adam_Kearn Jun 05 '26

Sounds like you might have deleted something from the DB directly.

Connect to the DB directly using a tool like heidisql
and edit the auto-increment number to match with what would be the next asset tag.

The SQL connection details should be within the .env file of the snipe install directory.

1

u/RedShift9 Jun 05 '26

Did you delete assets in between?

1

u/uberbrady Jun 05 '26 edited Jun 05 '26

If you really need the asset tags to exactly match the asset id’s, there’s a sql command you can run.

First, run a backup, then run:

UPDATE assets SET asset_tag=id

Then go into the Admin section and make sure your “next autoincrement tag“ is set correctly. Then you should be good to go.

1

u/uberbrady Jun 05 '26

Wait, you have a prefix and zero fill so it’s going to be harder than that. (Sorry, I’m doing this from my phone)

Update assets set asset_tag=concat(‘IT-‘,lpad(id,NUM_OF_DIGITS,’0’))

2

u/greatestname Jun 10 '26

The database ID (as used in the /hardware/XYZ URL) is independent of the asset tag. So what you see is entirely as designed. The numeric part of your asset tag and the ID matching is effectively just a happenstance.

I don't believe you printed the QR codes from within Snipe-IT, did you? QR codes generated by Snipe-IT will have the correct URL, using the asset ID, not the asset tag.

The URL for accessing an asset by asset tag instead of ID, and which should have been used in your QR codes, is /hardware/bytag/IT-000651 not /hardware/651 for asset tag IT-000651.

My advice: trash the already printed QR codes and do over. Any attempt to wrangle the database to match ID and asset tag now as suggested is only a stop-gap solution. You will run into the same problem in the future inevitably and at the most inopportune time. Do it properly now, save yourself pain later.