6

I have an inline visualforce page which uses a standard controller. I check values from the record object in javascript so I can display some other records in a popup based on the value of customfield.

Inline VF Page:

<apex:page standardController="MyObject__c" showHeader="false">
<apex:form id="myForm">
                <input type="button" id="someBtn" onclick="showPopup()" title="Click Here"/>
</apex:form>
<script> 
var id = '{!MyObject__c.Id}';
var fieldValue = '{!MyObject__c.CustomField__c}';  

function showPopup(){
    checks fieldValue and does something...
}
</script>
</apex:page>

This works fine on developer org with no issues but when this is added to managed package, on the org where package is installed I see this visualforce error:

Content cannot be displayed: SObject row was retrieved via SOQL without querying the requested field: namespace_MyObject_c.namespace_CustomField_c

I am not using extension here so cannot figure out why this error. Any idea what I am missing?

1 Answer 1

4

You need to include your organization namespace in the field which you mentioned in the java script {!Namespace_MyObject__c.Id}'; {!namesapce_MyObject__c.namesapce_CustomField__c}'

6
  • 1
    An alternative would be to use two string getters in an extension class, which would return myobject.Id and myobject.CustomField__c, that way you wouldn't have to worry about the prefix since the package creation would take care of it. Commented Aug 22, 2012 at 21:39
  • So much for namespace prefix not being needed for the package contents! This one just caught me out too.
    – Matt Lacey
    Commented Jan 10, 2013 at 2:05
  • 2
    I have the same problem, and I tried this. And then the same problem that was showing in the org were the managed packet was installed started happening in the dev org, is this still the solution to this problem?
    – Jose
    Commented Jun 6, 2014 at 18:32
  • 2
    I don't really recall this issue or what I did, but have you try using an <apex:variable var="c" value="{!MyObject__c.CustomField__c}"/> and then access the 'c' variable's value in your script? That should work for both dev and production orgs where the package is developed/installed. @raym0nd
    – Jose
    Commented Jan 13, 2016 at 19:36
  • 1
    I got the same problem, the apex:variable did resolve it. Thanks Jose. Commented Sep 26, 2017 at 14:25

You must log in to answer this question.

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