odekakeshimasyo.me

Salesforce Describe

API

Understanding Apex Describe Information
DescribeFieldResult Methods

Describeまわり

取得例
Schema.SObjectType Account.sObjectType;
Schema.DescribeSObjectResult Account.sObjectType.getDescribe();
Schema.SObjectField Account.Name;
Account.Name.getDescribe().getSObjectField();
Schema.DescribeFieldResult Account.Name.getDescribe();
Schema.DisplayType Account.Name.getDescribe().getType();
List Account.Industry.getDescribe().getPicklistValues();

■項目存在チェック

public Boolean hasColumn(SObject sobj, String columnName) {
	return Schema.getGlobalDescribe().get(sobj.getSObjectType().getDescribe().getName())
			.getDescribe().fields.getMap().containsKey(columnName.toLowerCase());
}