・要件
Salesforceオブジェクト項目一覧はワンタッチで取得する。
・対応案
ワンタッチできないが、ステップで取得方法は検討した。
①開発コンソールで、下記を実行する
Map<String, Schema.SObjectField> mapFields = Schema.getGlobalDescribe().get('Account').getDescribe().fields.getMap();
for (String fieldName: mapFields.keyset()){
System.debug('fieldName_Label:' +mapFields.get(fieldname)
+ ',' + mapFields.get(fieldname).getDescribe().getType()
+ ',' + mapFields.get(fieldname).getDescribe().getLabel()
);
}
上記ログをクリックし、ロカールに保存する
例:c:\tmp\apex-07_Accout.log
②PowerShellで一括抽出
(select-string '\|fieldName_Label' apex-07_Accout.log ) | foreach-object -Begin{new-item -type file -force a.csv} -Process { $b = $_ -replace '.*?Label\:'
''; write-output $b |out-file a.csv -append } -End{ get-content a.csv | sort-object | get-unique > Account.csv }
結果(Name,Type,Label)
AccountNumber,STRING,Account Number
AccountSource,PICKLIST,Account Source
......