Last active
August 2, 2017 10:46
-
-
Save 101dvlp/b4d3e948f717ac2fccb4bc16629463d1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class displaySObjectList { | |
public Map<String, List<String>> stdObj = new Map<String, List<String>>(); | |
public Map<String, List<String>> cstmObj = new Map<String, List<String>>(); | |
public Map<String, List<String>> getStdObject(){ | |
return stdObj; | |
} | |
public Map<String, List<String>> getCstmObject(){ | |
return cstmObj; | |
} | |
public void CreateObjectList(){ | |
// 全オブジェクトを取得 | |
Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe(); | |
List<String> keys = new List<String>(gd.keyset()); | |
// 全オブジェクトの内容を取得 | |
Schema.DescribeSObjectResult[] dsr = Schema.describeSObjects(keys); | |
// プレフィックスが存在するもののみ取得 | |
List<String> prefixList = new List<String>(); | |
for(Integer i = 0; i < dsr.size(); i++){ | |
String tmp = dsr[i].getKeyPrefix(); | |
if(tmp != null){ | |
prefixList.add(tmp); | |
} | |
} | |
prefixList.sort(); | |
for(String s : prefixList){ | |
for(Integer j = 0; j < dsr.size(); j++){ | |
if(s == dsr[j].getKeyPrefix()){ | |
List<String> objItems = new List<String>(); | |
objItems.add(dsr[j].getName()); | |
objItems.add(dsr[j].getLabel()); | |
if(dsr[j].isCustom()){ | |
cstmObj.put(s, objItems); | |
} else { | |
stdObj.put(s, objItems); | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment