+ Start a Discussion
unidhaunidha 

DUPLICATE_DEVELOPER_NAME while the Document already deleted

Hi,

 

I did some code to  insert Document thru apex and successfully work. For Document Name and Developer Name, I generate it dynamically  by concatenate it with some variables and object name. Something like below

docName= 'XX_'+autoNumber+'_'+accountName+'_'+ accountCountry;
		    	 
document.Name =docName;
document.DeveloperName=docName;
document.isPublic=true;
document.FolderId=folderId;
		    	
upsert document;

 

 

The issue is, I manually delete the Document  and run my apex code to insert  back the Document but I face this error:

 

First exception on row 0; first error: DUPLICATE_DEVELOPER_NAME, This Document Unique Name already exists or has been previously used.  Please choose a different name

 


Well,I do not understand why it prompt me this  error as I already deleted the Document.I already check the Document and it could not be found.

 

Here the method how I check the Document, unfortunately it return nothing.I also remove isDeleted and still it return nothing.If it return nothing, the duplicate issue should not happen at the first place as the Document is not there.Or is it different case for Document.

 

SELECT Name, DeveloperName, Type, IsDeleted FROM Document where DeveloperName like 'XX_100%' and isDeleted=true

 Thanks,

unidha

Avidev9Avidev9

Just have a look at the error message :

 

"This Document Unique Name already exists or has been previously used.  Please choose a different name"

unidhaunidha

Hi,

 

So that means, even the Document being deleted, it still cannot be duplicated? Just thinking how to avoid this Exception for Document insertion thru Apex controller.

 

Thanks,

unidha