You need to sign in to do that
Don't have an account?
Mrunali Gaonkar
Unique 6 digit code generation for web to lead
Hi,
following code is to generates 6 digit unique code i.e strPassword for web to lead using Lead Id and datetime value.This is working fine on sandbox as we create single record at a time.But what is probability that this following logic can fail on production??????? Code generated will be unique across or need to take some precaution to avoid errors.
// for loop over lead
strForEncryption = String.valueOf(oLead.id) + String.valueOf(Datetime.now().formatGMT('yyyy-MM-dd HH:mm:ss.SSS'));
blobHashCode = Crypto.generateDigest('MD5', Blob.valueOf(strForEncryption));
strHexDigest = EncodingUtil.convertToHex(blobHashCode);
strPassword = strHexDigest.substring(0,6);
following code is to generates 6 digit unique code i.e strPassword for web to lead using Lead Id and datetime value.This is working fine on sandbox as we create single record at a time.But what is probability that this following logic can fail on production??????? Code generated will be unique across or need to take some precaution to avoid errors.
// for loop over lead
strForEncryption = String.valueOf(oLead.id) + String.valueOf(Datetime.now().formatGMT('yyyy-MM-dd HH:mm:ss.SSS'));
blobHashCode = Crypto.generateDigest('MD5', Blob.valueOf(strForEncryption));
strHexDigest = EncodingUtil.convertToHex(blobHashCode);
strPassword = strHexDigest.substring(0,6);
https://developer.salesforce.com/page/Best_Practice%3A_Bulkify_Your_Code