apex 根据ID获取Object Name

public static Schema.SObjectType getSobjectTypeByPrefix( String SObjectPrefix ){
    for( Schema.SObjectType ot : Schema.getGlobalDescribe().values() ){
        String keyPrefix = (String)ot.getDescribe().getKeyPrefix();
        if( keyPrefix != null && keyPrefix.equals( SObjectPrefix ) ){
            return ot;
        }
    }
        return null;
    }

String sourceAPIName = getSobjectTypeByPrefix(sourceId.subString(0,3)).getDescribe().getName();

posted @ 2012-10-16 15:18  hoho,SalesForce  阅读(441)  评论(0编辑  收藏  举报