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. If you can't find the document with this UID value, then that means that one of your documents used to have this UID value and now it is locked.

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 an old UID value can not be reused on a different document. If you try to use an old UID name on a different document you will receive the error mentioned above.
 

Preventing an old url from appearing on your site

To prevent a page from appearing with the old url, we suggest that you do a 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

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

In order 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 in order 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.

Did this answer your question?