Category Archives: apex

Determine if field is a component of a compound field

Sometimes there is a need to determine if a field is a component of a compound field. For example, compound fields components are not permissionable even though field describe isPermissionable method for them returns true. There might be other cases … Continue reading

Posted in apex, field, SOQL | Leave a comment

Determine by Apex if Custom Field allows setting Field Level Security

There is FieldDefinition standard object, which is available in usual SOQL and in Tooling API. However, this object has different fields available in different ways of accessing it. It has a field IsFlsEnabled which is only available in Tooling API, … Continue reading

Posted in apex, field, salesforce | Tagged , , , , , , , , | Leave a comment

Efficient dynamic SObjectType retrieval in Salesforce

It is interesting how often we use inefficient code. For example, if we want dynamically get SObjectType for given custom object by its String representation, how do we usually implement it? Have you seen code like following? public static SObjectType … Continue reading

Posted in apex, salesforce | Tagged , , , | Leave a comment

Salesforce: get applications and tabs profile assignments

Salesforce: get application names, application profile assignment, custom tab profile access availability, app to tab correspondence. To Get Custom and Standard Application Names run usual Apex SOQL query: select Id, ApplicationId, Name, Type from AppMenuItem where Type = ‘TabSet’ To … Continue reading

Posted in apex, salesforce, Uncategorized | Tagged , , , , , , , | Leave a comment

Salesforce: use Apex Code to grant permissions to custom object and fields

List<Id> profilePermissionsSetIds = [ select id, Profile.UserLicense.Name from PermissionSet where IsOwnedByProfile = true and Profile.UserLicense.Name = ‘Salesforce’]; List<ObjectPermissions> objPermissions = new List<ObjectPermissions>(); for ( String pId: profilePermissionsSetIds ) { objPermissions.add( new ObjectPermissions ( SObjectType = ‘Custom_Object__c’, ParentId = pId, PermissionsRead … Continue reading

Posted in Administration, apex, Profile, salesforce, Uncategorized | Tagged , , , , , , , , , | Leave a comment

Get SObjectName by Key Prefix

This documentation link code returns empty for hidden SObject Types, while this version of code presented below works just fine

Posted in apex, salesforce, Uncategorized | Tagged , , | Leave a comment