Using .KeySet()
on a map, we will get a list of all the keys returned.
Map<Id, Master_Obj__c> masterMap = new Map<Id, Master_Obj__c>([SELECT Id, Name FROM Master_Obj__c]);
List<Detail_Obj__c> objDetailList = [Select Id, Name FROM Detail_Obj__c WHERE Master_Obj__c IN :masterMap.KeySet()]
Loading...
Set <String> accNames = new Set <String> {'Test%', 'Sample%'};
List <Account> accList = [SELECT Id FROM Account WHERE Name LIKE : accNames];
Loading...
Sample Code:
SELECT Id, ValidationName, Description, EntityDefinition.DeveloperName, ErrorDisplayField, ErrorMessage FROM ValidationRule Where EntityDefinition.DeveloperName='<Object Name>' And Active = true
Note: To query use Tooling API
Loading...
For Specific Profile :
List<FieldPermissions> fpList = [SELECT SobjectType, Field, PermissionsRead, PermissionsEdit, Parent.ProfileId FROM FieldPermissions WHERE SobjectType = 'Account' and Field='Account.Customer_Priority__c' AND Parent.ProfileId IN (SELECT Id FROM PermissionSet WHERE PermissionSet.Profile.Name = 'System Administrator')];
if(!fpList.isEmpty()){
Boolean hasReadPermission = fpList[0].PermissionsRead;
Boolean hasEditPermission = fpList[0].PermissionsEdit;
system.debug('Read Permission - ' + hasReadPermission);
system.debug('Edit Permission - ' + hasEditPermission);
}
For Current User :
List<FieldPermissions> fpList = [SELECT SobjectType, Field, PermissionsRead, PermissionsEdit, Parent.ProfileId FROM FieldPermissions WHERE SobjectType = 'Account' and Field='Account.Customer_Priority__c' AND Parent.ProfileId=:Userinfo.getProfileId()];
if(!fpList.isEmpty()){
Boolean hasReadPermission = fpList[0].PermissionsRead;
Boolean hasEditPermission = fpList[0].PermissionsEdit;
system.debug('Read Permission - ' + hasReadPermission);
system.debug('Edit Permission - ' + hasEditPermission);
}
Loading...
Using below SOQL query we can get organizations default currency in a multiple currency organizations.
Sample Code:
String defaultCurrencyCode = [SELECT IsoCode FROM CurrencyType WHERE IsCorporate = true].IsoCode;
System.debug('DefaultCurrencyCode-' + defaultCurrencyCode);
Loading...