function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Nir Keren 14Nir Keren 14 

getGlobalDescribe() is not working for 'Lead'

Hi All,

String SobjectApiName = 'Lead';
 Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
 Map<String, Schema.SObjectField> fieldMap = schemaMap.get(SobjectApiName).getDescribe().fields.getMap();
system.debug('***' + fieldMap);

following code works great on dev but when i put it in managed package its returning NULL, i am running the package as Admin and i have permissions to view/read/write 'Lead' .
more wierd is that its working for 'Account'

Please HELP.
 
SandhyaSandhya (Salesforce Developers) 
Hi Nir Keren,


Dynamic Apex, contained in managed packages created by salesforce.com ISV partners that are installed from Force.com AppExchange, have restricted access to any sObject outside the managed package. Partners can set the API Access value within the package to grant access to standard sObjects not included as part of the managed package. While Partners can request access to standard objects, custom objects are not included as part of the managed package and can never be referenced or accessed by dynamic Apex that is packaged.​

Try to set Enable Restrictions or Restricted, in API setting and see.

Please refer below link.

https://help.salesforce.com/HTViewHelpDoc?id=editing_client_security_profile.htm&language=en_US
 
https://help.salesforce.com/HTViewHelpDoc?id=about_client_security_profile.htm&language=en_US
 
Hope this helps you!

Please mark it as Best Answer if my reply was helpful. It will make it available for other as the proper solution.
 
Thanks and Regards
Sandhya