Another Salesforce blog!!!

Salesforce, Apex

Dynamic Apex

create instance of sobject dynamically

public SObject getNewSobject(String t) { // Call global describe to get the map of string to token. Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe(); // Get the token for the sobject based on the type. Schema.SObjectType st = gd.get(t); // Instantiate the sobject from the token. Sobject s = st.newSobject(); return s; } system.debug(‘///’ + getNewSobject(‘Speaker__c’) ); […]

get the list of all available sobject in salesforce database using Apex (Dynamic Apex)

Map<String, Schema.SObjectType> m = Schema.getGlobalDescribe() ; system.debug(‘///’ + m ); Favorite

Next posts