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?

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}'

  • 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. – James Loghry Aug 22 '12 at 21:39
  • So much for namespace prefix not being needed for the package contents! This one just caught me out too. – Matt Lacey Jan 10 '13 at 2:05
  • 1
    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 Jun 6 '14 at 18:32
  • @Jose were you able to find a solution for that? – raym0nd Jan 13 '16 at 19:16
  • 1
    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 Jan 13 '16 at 19:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.