• Maureen Ezekwugo
  • NEWBIE
  • 0 Points
  • Member since 2015

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

Hello - I need help with building a GIUD (UUID) in SFDC? we are revamping our integration with our IT department and they want me to build a GUID in SFDC. I have never done this and have no idea where to start. I have found some sample code and this dosent work?

 

global class guidGenerator {

    private static String kHexChars = ’0123456789abcdefABCDEF’;

    global static String generateGUID(){

        String returnValue = ”;
        Integer nextByte = 0;
        for(Integer i = 0; i < 16; i++){
            if(i==4 || i==6 || i==8 || i==10){
                returnValue += ‘-’;
            }
            
            nextByte = (Math.round(Math.random() * 255)-128) & 255;

            if(i==6){
                nextByte = nextByte & 15;
                nextByte = nextByte | (4 <> 4);
            returnValue += charAt(kHexChars,nextByte & 15);
        }
        return returnValue;
    }

    public static String charAt(String str, Integer index){
        if(str == null){
            return null;
        }
        if(str.length() <= 0){
            return str;    
        }
        if(index = str.length()){
            return null;    
        }
        return str.substring(index, index+1);
    }
}

 

ANY help would be much appriciated.

 

Thank you!

NIki

  • September 14, 2012
  • Like
  • 0