Activity Forums Salesforce® Discussions How to get list of All Objects enabled with Activities in Salesforce?

  • Surbhi

    Member
    May 26, 2016 at 6:35 am

    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

  • Piyush

    Member
    May 26, 2016 at 10:53 am

    Hello Surbhi,

    Thanks for the response its work for me.

     

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos