Error: This value is already used by another document

When adding a value to your UID field, you may encounter the following error:

This value is already used by another <custom-type-name> document

This means that another document in your repository already has this UID value. It could be a document that is drafted or in the archive. If you can't find the document with this UID value, that means that one of your documents used to have this UID value, and now it is locked. In order to re-assign a UID, you must delete the document that currently has that UID.

This article will explain why an old UID becomes locked and how to unlock it.

Old UID Values

A UID field will save all previous UID values.

We save all the previous UID values of a given document so that your old links won’t be broken on your site when you change a UID value.

Because the UID value must be unique, this means that the document can not reuse an old UID value on a different one. If you try to use an old UID name on a different document you will receive the above error.

Preventing an old URL from appearing on your site

To prevent a page from appearing with the old URL, we suggest that you check with each URL to see if the UID received is the current one. If so, then load the page; if not, then redirect to the current URL.

Finding, removing, & unlocking an old UID value from a document

Let's say that you have an old UID value called "old-uid" that you wish to reuse on another document.

To use it again, you need to figure out which document has that value. To do this, go to your API browser (make sure to replace "your-repo-name" with the URL name for your repository):

https://your-repo-name.prismic.io/api

Then enter the following into the query field, making sure to add the correct Custom Type API ID in place of "your-custom-type":

[at(my.your-custom-type.uid, "old-uid")]

Then search your documents, and the document that contains "old-uid" as a previous UID value should appear.

Note that if your repo uses more than one language, you might need to add the lang parameter to your URL to see the document. After you have performed the search above, add &lang=* to the query URL, load the page, and the result should appear.

Once you've found the document, you need to duplicate it. You can do this by going to the edit page for that document, then clicking on the Duplicate button at the top of the screen.

After you've duplicated it, you can delete the original, and this will allow you to use "old-uid" again.

Threads close after a period of inactivity. Flag this thread to re-open it and continue the conversation.

Hey,

But in my case, I use UIDs as the page paths.
And when I want to add a link in page (A) to point to page (B), I do that by linking the page documents internally (i.e. add a link in page A document pointing to page B document). So if I duplicate and delete the old document of page (B) all the links to page (B) in other documents will be broken.

Also, according to SEO, it is not recommended to have 2 urls serving the same content. Is there any way I can unlock the old UIDs to reuse them without deleting the old page document?

Thanks :slight_smile:

Hello @mahmoud.elbayoumy, Yes. If you delete a document you'd need to re-add the links where you used it. For the moment this is the only workaround to reuse an existing old UID.

Hello,

It's quite a problem to not be able to edit old-uid. Have your feature team have planned to do something about it ? Because when we duplicate a document we lose all international links... Or maybe you could add a feature to link translated content between them.

Have a good day.
Maxime

Hello @maxime.hersand

Duplicating a document is making a copy of that sole document. Nothing else gets duplicated except that one. In the duplicated version, all content will be the same, including Links to other documents, but these are just references to those docs. It doesn’t mean they get duplicated as well.

We are already tracking it as a feature request for future improvement.

Thanks for pointing this out.

Priyanka