Hi Piyush,
I think you require list of all objects enabled with activities in apex. The most accurate way is to loop over the list of valid target Objects of the WhatId field on the Task or Event object, as this list will change whenever you check/uncheck the “Allow Activities” checkbox on a given Object:
Set<Schema.SObjectType> objectsWithActivitiesEnabled = new Set<Schema.SObjectType>();
String objectNames = ”;
for (Schema.SObjectType objectType : Task.WhatId.getDescribe().getReferenceTo()) {
objectsWithActivitiesEnabled.add(objectType);
objectNames += ‘\n’ + objectType;
}
system.debug(objectNames);
Thanks