Explore Courses Blog Tutorials Interview Questions
0 votes
in Salesforce by (11.9k points)

I'm working on a Salesforce Application. The application contains some custom objects, one of which is Project. I have created a Visualforce page to manage these projects. We are also developing an extension. In the extension, a new custom field is added to the Project object. In the original package, I want to change the visualforce page to show whether the value of that field (if the extension is installed). So I need to check if the extension is installed, and if so, display afield from that extension.

Is there any way to do that?

1 Answer

0 votes
by (32.1k points)
edited by

So, if you have installed a Chatter Unfollow app from AppExchange and want to rely on its' objects:

String objectName = 'chttrunfollow__UnfollowRule__c';

String fieldName = 'chttrunfollow__Active__c';

Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe();

Schema.SObjectType t = gd.get(objectName);

if(t != null) {

    Schema.DescribeSObjectResult sobjectDescribe = t.getDescribe();


    Map<String, Schema.SObjectField> fields = sobjectDescribe.fields.getMap();

    if(fields != null && fields.get(fieldName) != null && fields.get(fieldName).getDescribe().isAccessible()) {

        System.debug('Show it!');


} else {

    System.debug(LoggingLevel.ERROR, 'Not found');


It can be a quite expensive operation so you'd probably want to cache the results somewhere (custom setting?).

There's a System.requestVersion() call but I think it returns only "your" current version (can't use it to ask for what else was installed in given org). if you use licenses - UserInfo.isCurrentUserLicensed('namespace') might be worth checking?

Want to get certified in Salesforce? Here is the Salesforce Online Training you are looking for.

Browse Categories