Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
Namespace Prefix
After a developer registers a globally unique namespace prefix and registers it with AppExchange registry, external references to custom object and field names in the developer's managed packages take on the following long format:
1namespace_prefix__obj_or_field_name__cThese fully qualified names can be onerous to update in working SOQL or SOSL statements, and Apex once a class is marked as “managed”. Therefore, Apex supports a default namespace for schema names. When looking at identifiers, the parser assumes that the namespace of the current object is the namespace of all other objects and fields unless otherwise specified. Therefore, a stored class must refer to custom object and field names directly (using obj_or_field_name__c) for those objects that are defined within its same application namespace.
In managed package Apex, that default resolution can cause duplicate field name errors if a subscriber creates a local custom field with the same API name as a packaged field. To control how unqualified and namespace-qualified field names resolve in dynamic SOQL, see Prevent Field Name Collisions in Managed SOQL Queries.
Using Namespaces When Invoking Package Methods
To invoke a method that is defined in a managed package, Apex allows fully qualified identifiers of the form:
1namespace_prefix.class.method(args)Versioned Behavior Changes
In API version 34.0 and later, Schema.DescribeSObjectResult on a custom SObjectType includes map keys prefixed with the namespace, even if the namespace is that of currently executing code. If you work with multiple namespaces and generate runtime describe data, make sure that your code accesses keys correctly using the namespace prefix.