Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trigger tokenGenerator on Certification__c (before insert) {
- static string randomString(){
- for(Certification__c c: Trigger.new){
- final String chars = 'BCD';
- String a = '';
- while (a.length() < 1) {
- Integer idx = Math.mod(Math.abs(Crypto.getRandomInteger()), chars.length());
- a += chars.substring(idx, idx+1);
- }
- }
- return a;
- }
- Integer i;
- if(i<100){
- while(c.Name.contains(a)){
- randomString();
- i++;
- }
- c.Name = a;
- }
- else
- c.Name = 'You ran out of TOKENS';
- }
Add Comment
Please, Sign In to add comment