LoginSignup
0
1

More than 1 year has passed since last update.

Salesforceオブジェクト項目一覧の取得

Posted at

・要件

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()  
                 ); 
}   


image.png

上記ログをクリックし、ロカールに保存する
例: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
......
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1