I am working on a method defined in a class that controls the lead object. The desired end result is to produce a unique number for each Lead record. I currently have this working, but the out put is a hex value and I need it to be integer. The field to populate is called "Unique_Reference_number__C". An auto-number field is not sufficient, as there are different formats applied contingent on lead field values. Is there a simple way to convert a hex value to an integer? Here is my method:
private void GenerateRandomNumber(List<Lead> lList){
System.debug('*lList*********** '+lList.size());
for(Lead l: lList){
if(l.Unique_Reference_number__c==null || l.Unique_Reference_number__c==''){
System.debug('*1*********** ');
Integer len = 7;
Blob blobKey = crypto.generateAesKey(128);
String key = EncodingUtil.(blobKey);
String pwd = 'ID'+key.substring(0,len);
l.Unique_Reference_number__c= pwd;
System.debug('*1*********** '+pwd);
}