DML check in Salesforce Apex

Option 1:

System.debug(
    'Create Allowed? ' + 
    Schema.sObjectType.Account.isCreateable()
);
System.debug(
    'Update Allowed? ' + 
    Schema.sObjectType.Account.isUpdateable()
);
System.debug(
    'Delete Allowed? ' + 
    Schema.sObjectType.Account.isDeletable()
);

Option 2:

DescribeSObjectResult sobjectRes = Account.sObjectType.getDescribe();
System.debug(
	'Object Label is ' + sobjectRes.getLabel()
);
System.debug(
	'Key prefix is ' + sobjectRes.getKeyPrefix()
);
System.debug(
	'Plural Label is ' + sobjectRes.getLabelPlural()
);
System.debug(
	'Object Name is ' + sobjectRes.getName()
);
System.debug(
	'Is Object queryable by current user? ' + 
	sobjectRes.isQueryable()
);
System.debug(
	'Is Object createable by current user? ' + 
	sobjectRes.isCreateable()
);  
System.debug(
	'Is Object updateable by current user? ' + 
	sobjectRes.isUpdateable()
);   
System.debug(
	'Is Object deletable by current user? ' + 
	sobjectRes.isDeletable()
); 

Leave a Reply