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
XactiumBenXactiumBen 

Dynamic Apex and Packaging Issue

I recently heard that packaging up apex classes that utilise dynamic apex breaks the code.  I was wondering whether this was an outstanding issue, or it has been resolved.

Dynamic Apex seems to work fine for me when packaging, but using Schema.getGlobalDescribe() only seems to get me one custom object - I only have one custom object in my account at the moment, which is being packaged up.  Before packaging, I had access to all objects (i.e. Accounts, Opportunities etc.)

Maybe the Schema.getGlobalDescribe() method is only getting objects in my package?  Migrating my code using ANT into a totally new salesforce account seems to fix my current issue.

Can we expect a fix for this soon?


Message Edited by XactiumBen on 11-14-2008 11:33 AM
tmatthiesentmatthiesen
When packaging Dynamic Apex you need to be aware of the following restrictions:

1) When Dynamic Apex is added to a package, by default, it only has access to custom objects  (eg: namespaced custom objects/fields) which are included in the package.
2) You must enable API access on the Package to access Standard Objects (if you don't enable it, Dynamic Apex will not have
     access to Standard Objects)  To enable PAC follow these steps:
       a) on the Package detail screen, set API Access to "Enable Restrictions"
       b) this redirects you to the PAC screen.  This screen provides the ability to explicitly request access to a set of Standard Objects
       c) by selecting a Standard Object - you gain access to the Standard fields on the Object as well as any namespaced fields (custom fields) that are included as part of your package
 3) Packaged Dynamic Apex does not have access to Customer created extensions, eg: customer created custom objects, custom fields.  This is a known issue.  SFDC is looking at options to support dynamic access to customer extensions, specifically custom fields that are added to Standard Objects as well as customer extensions to packaged Custom Objects.
wintamutewintamute

tmatthiesen wrote:
3) Packaged Dynamic Apex does not have access to Customer created extensions, eg: customer created custom objects, custom fields.  This is a known issue.  SFDC is looking at options to support dynamic access to customer extensions, specifically custom fields that are added to Standard Objects as well as customer extensions to packaged Custom Objects.



Any guesstimate on this?
This usecase would be the only reason for us to use dynamic apex in the first place, to support custom fields added by the customer after installing the package.
I'd just like to know if we better stick to our hardcoded fieldname approach for now or if it makes sense to use dynamic apex, depending on if we will see these enhancements in the not so far future.

XactiumBenXactiumBen
Thanks for the solutions.  It's a shame that there is that bug with packaged dynamic apex.

I too would like to know the expected fix date for this bug.  My whole app uses dynamic apex so I'm hoping it will get fixed soon so the app can be released on the AppExchange.