2

I am busy creating a managed package with my own namespace in Developer Edition, and would like to create a custom field on the Lead standard object that does not have my namespace prefixed. I will use this field in my Apex classes, but will not include it in the final package. The target org will have this field already created (so it is basically a custom field dependency).

Is this possible?

2 Answers 2

3

No (mostly). There is a bug I found where a non-namespaced field appeared in my developer org, but I can't reliably reproduce it.

Any fields you create through normal means will be namespaced. Further, if you accidentally upload your package with this field referenced or included, you're in for a Bad Time™.

If you must have the field in your managed package, make sure you reference it only dynamically, and allow your code to fail gracefully if not present.

Keep in mind that it's okay for your field to have the namespace, as the package will resolve it dynamically for you. As long as you're careful, you should be just fine.

1

You can not.Once namespace get enabled for org, it get appended to nearly all components api name.

It seems that you want to refer a custom field outside of your managed package, so for that you will need to refer that field dynamically, that way it will not be checked by compiler and will be decided at run time,at that time you can check whether namespaceprefix is enabled for that org or not, if it is enabled then append it with field's api name other wise not.

You can check whether namespace is enabled or not for particular organization from following query:

SELECT NamespacePrefix FROM Organization

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .