+ Start a Discussion
SeAlVaSeAlVa 

can IDs be repeated?

Hi, 

 

In order to allow backing-up and restoring our system, we need to create External IDs on every object, so external items would store the custom object.

 

My initial Idea was to create a field called ID__c marked as unique and External ID.

on after insert, if this field is null, I would assign its real ID.

It would be left as it is, otherwise.

 

Now suppose that we create a record
ID: A

Name: Data1
ID__c: null
this would make ID__c --> A

 

if I delete this record and restore it from a back-up, I would have

ID: B (would assign a different, as you cannot control which ID is given on insert)

Name: Data1

ID__c: A

 

The question is, is it possible that at some point in the future, I try to create a record and salesforce give it the ID A (as it is no longer used)?

In the scenario I stated, It would fail the insert, cause ID__c is unique, but I want to know if salesforce reuses IDs.

 

I know that it is very unlikely, but I'm just wondering.

Best Answer chosen by Admin (Salesforce Developers) 
Ashish_SFDCAshish_SFDC

Hi  Sealva, 

 

Salesforce works on Object Based architecture, where record Ids and meta data Ids are auto generated which are unique to your Org and Can never be same for any future Objects. 

 

I would suggest you to Use the same Salesforce ID which when Exported converst itself to a 18 digit Case Insensitive IDs. Which otherwise are 15 digit alphanumeric Case Insensitive Inside Salesforce. 

 

Even the external Ids would not be similar in any case. 

 

Regards,

Ashish

All Answers

digamber.prasaddigamber.prasad

Hi,

 

NO in salesforce, ID of a record will never be allocated to other record.

Ashish_SFDCAshish_SFDC

Hi  Sealva, 

 

Salesforce works on Object Based architecture, where record Ids and meta data Ids are auto generated which are unique to your Org and Can never be same for any future Objects. 

 

I would suggest you to Use the same Salesforce ID which when Exported converst itself to a 18 digit Case Insensitive IDs. Which otherwise are 15 digit alphanumeric Case Insensitive Inside Salesforce. 

 

Even the external Ids would not be similar in any case. 

 

Regards,

Ashish

This was selected as the best answer
SeAlVaSeAlVa

Ok, 

just wanted to be sure, just in case salesforce reused deleted element IDs (really deleted, not with isDeleted=true)  to reduce IDs consumption.

Thanks u 2

 


Ashish_SFDC wrote:

Even the external Ids would not be similar in any case. 

 


I'll copy 18 character ID. I know I'll waste an update dml, but otherwise, I'll have to implement a way to generate external IDs that can be loaded without having to change field types, etc. 

 

And also, Standard insert web-services will return the real ID, so if I copy it, I don't force external systems to request the auto-generated external ID.

 

Regards

Ashish_SFDCAshish_SFDC

Hi  Sealva, 

 

 

There is a function in formulas called " CASESAFEID(Id) " which returns the 18 character ID, you can use that, you can also hide that from the page layout for non admin users via profile. 

 

See the image in the link below, 

 

http://srlawr.blogspot.in/2012/09/outputting-salesforce-18-character-id.html

 

Regards,

Ashish

Ashish_SFDCAshish_SFDC

 

 

CASESAFEID

Description:Converts a 15-character ID to a case-insensitive 18-character ID.
Use:CASESAFEID(id) and replace id with the object’s ID.
Example:
CASESAFEID (Id)

This formula replaces the 15-character ID with the 18-character, case-insensitive ID.

Tips:
  • Convert to 18-character IDs for better compatibility with Excel.
  • The CASESAFEID function is available everywhere that you can define a formula except reports and s-controls.

 

 

https://help.salesforce.com/HTViewHelpDoc?id=customize_functions_a_h.htm&language=en_US#CASESAFEID

 

Regards,

Ashish