• HITESH GODHA
  • NEWBIE
  • 0 Points
  • Member since 2016
  • Associate Consultant Trainee
  • Appirio


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
 Hi,

I have a requirement with my client wherein we are required to generate a unique random number on creation of a record in the system.

To cater to which I have written a below line of code-

integer max=6;
string password=EncodingUtil.ConvertToHex(crypto.generateAesKey(128)).substring(1,max);
recordToUpdate.put('Seller_Code__c'),'S'+password);

this code works fine.But not sure whether this code will generate a unique random number everytime.Can anyone help me with this?

In case if this code does not generates a unique random number how can I handle through same code?