I've created a function that determines if an object is real and (in this case) setting a variable to true/false based in that result. That value is then used to set a vf variable that will later be used to show or hide an html element:
VF page section
<apex:variable var="hideRecurring" value="{!IF(!showRecurring,'hide-content','')}" />
VF Controller
this.showRecurring = Helper.isRealObjectName('npe03__Recurring_Donation__c');
Helper.isRealObjectName
public static Boolean isRealObjectName(String objName) {
Boolean isReal = false;
// 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(objName);
if(null != st) {
isReal = true;
}
return isReal;
}
This works fine in a development environment (showRecurring = true), however in a managed package it does not (showRecurring = false). npe03__Recurring_Donation__c exists in both places.
If I run the isRealObjectName logic in the Developer Console on the server with the managed package, "isReal" = true;
Is there anything in a managed package that would cause this behavior?
with sharing
. The other links you provided helped me solve the problem (thank you!!!). Basically, I had to make 'API Access' Unrestricted for my package before I uploaded it. If you'd like to add an answer with that info I'll accept it, or I can add the answer if you don't want to.