+ Start a Discussion
Jordan@BracketLabsJordan@BracketLabs 

Namespace Prefixed Objects don't exist in Packaging Org

I understand that Salesforce's runtime will automatically append necessary namespace prefixes to Apex code references to custom sobjects and fields in a managed packaged.

 

Furthermore, I understand that it will not pick up references in Javascript, Dynamic SOQL & VF Pages, or hardcoded PageReferences (so these must be manually updated). 

 

I have however discovered something I don't understand:

 

1. We have a VF page that references a custom extension of the StandardController, as such we use the following work-around to get the standard controller to query all the necessary table columns in our custom object at load time:

 

//Works in Packaging Org
<apex:outputPanel rendered="false">
{!Object__c.ObjectField__c} {!Object__c.ObjectField1__c}
</apex:outputPanel>

 ^ The above code works properly in the packaging org, with a managed package created with a namespace prefix.

However, when it's installed into another org it doesn't work unless we manually prepend the namespace prefix as follows:

//Works in destination org, but not packaging org
<apex:outputPanel rendered="false">
{!NS1__Object__c.NS1__ObjectField__c} {!NS1__Object__c.NS1__ObjectField1__c}
</apex:outputPanel>

The above works in the destination org, but not packaging org.

 

 

Shouldn't my packaging org now be capable of respecting references to NS1__Object__c? 

Best Answer chosen by Admin (Salesforce Developers) 
cgosscgoss

We've seen this type of thing happen at times, but it seems to only happen when the field is directly merged into the page. Try replacing these with 

<apex:inputHidden value="{!Object__c.ObjectField__c}"/>

 I've never see a field referenced in this way have namespace issues, and it has the same effect of pulling it into the controller record.

 

- Chuck

All Answers

cgosscgoss

We've seen this type of thing happen at times, but it seems to only happen when the field is directly merged into the page. Try replacing these with 

<apex:inputHidden value="{!Object__c.ObjectField__c}"/>

 I've never see a field referenced in this way have namespace issues, and it has the same effect of pulling it into the controller record.

 

- Chuck

This was selected as the best answer
aalbertaalbert

If you are developing the VF page in the Developer Edition org where you defined the namespace, the system automatically will handle the namespacing context for you within VF. 

 

If you install the managed package into another org and then create a VF page (unmanaged), that VF page will need to explicitly reference/prepend the namespace. 

Jordan@BracketLabsJordan@BracketLabs

@aalbert -- 

 

I was able to get it working with the following:

 

<apex:inputHidden value="{!NS1__Object__c.NS1__ObjectField__c}"/>

 But direct references didn't work inside a non-rendered output panel (maybe because it wasn't rendered?)