+ Start a Discussion
admintrmpadmintrmp 

Is there a method for "Allow Activities"?

We have a relatedList on our custom Visualforce page and we are trying to work out a method either in Apex or Visualforce that allows us to determine whether Activities have been enabled on the object or not. I am finding it a little hard to find anything here that allows us to do this. We are currently working around this by having our own custom setting but it would be better to have everything managed in a single place.

 

I have had a quick look at globalDescribe() methods and I am wandering if there is anything in $ObjectType.

Best Answer chosen by Admin (Salesforce Developers) 
admintrmpadmintrmp

I've worked it out. I've built a small bit of code that allows the app to recognize if Activities have been enabled. Hopefully this will be useful to anyone else who needs to know:

 

Schema.DescribeSObjectResult r = customobject__c.SObjectType.getDescribe();

for ( Schema.ChildRelationship c : r.getChildRelationships() ) {
    if ( c.getRelationshipName() == 'OpenActivities' ) {
        System.debug('Activities are allowed.');
    }
}