Dynamic string formation: --> \'\' --> \'''\' --> \''+ +'\' --> \''+ test.Name +'\'
Query Custom Setting Records :
String regionQuery = 'SELECT Id, Name FROM TestCustomSetting__c';
List<TestCustomSetting__c> regionCustomSettings= Database.query(regionQuery);
Map<String, TestCustomSetting__c> countryMatrix = new Map<String, TestCustomSetting__c>();
for(TestCustomSetting__c region : regionCustomSettings){
countryMatrix .put(region.Name, region);
}
system.debug('countryToRegionTaskMatrix==>'+countryToRegionTaskMatrix);
https://www.infallibletechie.com/2012/10/map-datat-type-in-salesforce.html
https://salesforce.stackexchange.com/questions/223189/get-values-from-a-map-in-apex
SObject Query:
String typeName = 'Test__c';
SObjectType objectType = Schema.getGlobalDescribe().get(typeName);
Map<String,Schema.SObjectField> objectFields = objectType.getDescribe().fields.getMap();
String query = '';
Integer fieldCount = 0;
for (Schema.SObjectField objectField : objectFields.values()) {
if ('' + objectField != 'Test__c') {
query += objectField + ' ';
if ( fieldCount < objectFields.values().size() - 1) {
query += ', ';
}
}
fieldCount++;
}
system.debug('query==>'+query);
No comments:
Post a Comment