Skip to main content
Case Object record Id Should always start with "500........" in any SandBox or Production or Developer Edition

or anywhere in Salesfore whatever the region may be..?

What about remaining objects like Account , Opportunity..etc...

 
3 个回答
  1. 2015年7月1日 13:33
    Hi B kld,

    Yes you are Right, Below are the prefix for all other object.

    Entity                                                        Prefix

     

        ACCOUNT                         '001'

        QUOTE                           '0Q0'

        NOTE                            '002'

        CONTACT                         '003'

        USERS                           '005'

        OPPORTUNITY                     '006'

        ACTIVITY                        '007'

        OPPORTUNITY_HISTORY             '008'

        FORECAST_ITEM                   '00A'

        FILTER                          '00B'

        DELETE_EVENT                    '00C'

        ORGANIZATION                    '00D'

        USER_ROLE                       '00E'

        QUEUE                           '00G'

        GROUPS                          '00G'

        PARTNER                         '00I'

        OPPORTUNITY_COMPETITOR          '00J'

        OPPORTUNITY_CONTACT_ROLE        '00K'

        CUSTOM_FIELD_DEFINITION         '00N'

        REPORT                          '00O'

        ATTACHMENT                      '00P'

        LEAD                            '00Q'

    Please check below post to check other object prefix also

    https://help.salesforce.com/apex/HTViewSolution?urlname=Standard-Field-Record-ID-Prefix-Decoder&language=en_US (https://help.salesforce.com/apex/HTViewSolution?urlname=Standard-Field-Record-ID-Prefix-Decoder&language=en_US)

    You can get prefix of any custom object by below code:-

    Schema.DescribeSObjectResult r = CustomObject__c.sObjectType.getDescribe();

    String keyPrefix = r.getKeyPrefix();

    System.debug('Printing --'+keyPrefix );

    you can try below code to get prefix:-

    public class SchemaGlobalDescribe{

    public static String findObjectNameFromRecordIdPrefix(String recordIdOrPrefix){

    String objectName = '';

    try{

    //Get prefix from record ID

    //This assumes that you have passed at least 3 characters

    String myIdPrefix = String.valueOf(recordIdOrPrefix).substring(0,3);

    //Get schema information

    Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe();

    //Loop through all the sObject types returned by Schema

    for(Schema.SObjectType stype : gd.values()){

    Schema.DescribeSObjectResult r = stype.getDescribe();

    String prefix = r.getKeyPrefix();

    System.debug('Prefix is ' + prefix);

    //Check if the prefix matches with requested prefix

    if(prefix!=null && prefix.equals(myIdPrefix)){

    objectName = r.getName();

    System.debug('Object Name! ' + objectName);

    break;

    }

    }

    }catch(Exception e){

    System.debug(e);

    }

    return objectName;

    }

    }

    Please below post for more detail.

    https://help.salesforce.com/apex/HTViewSolution?urlname=How-to-find-Object-Type-from-Record-ID-Prefix&language=en_US (https://help.salesforce.com/apex/HTViewSolution?urlname=How-to-find-Object-Type-from-Record-ID-Prefix&language=en_US)

    NOTE:- Prefix for standard object will be same in all org but custom object can be differnt. you can try below code to get custom object prefix.

    Schema.DescribeSObjectResult r = CustomObject__c.sObjectType.getDescribe();

    String keyPrefix = r.getKeyPrefix();

    System.debug('Printing --'+keyPrefix );

    Please mark this as solution if this will help you. So that if some one has same issue this post can help other also.

    Thanks,

    Amit Chaudhary
0/9000