You need to sign in to do that
Don't have an account?

Error: Content cannot be displayed: SObject row was retrieved via SOQL without querying the requested field
Hello,
Having trouble editing some Visualforce code. I'm trying to edit the AccountHierarchyTree component from the Inline Account Hierarchy Visualforce page (https://appexchange.salesforce.com/listingDetail?listingId=a0N300000016chCEAQ) so it shows a custom Account field, but I get a "Content cannot be displayed: SObject row was retrieved via SOQL without querying the requested field: Account.Project__c" error. Edited section of code:
<!-- Include the following if you uses sites with accounts -->
<apex:outputText style="{!IF(pos.currentNode,'font-weight: bold;','')}" value=", {!pos.account.Type}" rendered="{!IF(pos.account.Type != '', true, false)}"/>
<apex:outputText style="{!IF(pos.currentNode,'font-weight: bold;','')}" value=", {!pos.account.Name}" rendered="{!IF(pos.account.Name!= '', true, false)}"/>
<apex:outputText style="{!IF(pos.currentNode,'font-weight: bold;','')}" value=", {!pos.account.Industry}" rendered="{!IF(pos.account.Industry!= '', true, false)}"/>
<!-- Stop -->
If I change account.Project__c to account.Name, Industry, or Type it works fine; all other fields I've tested don't.
Wondering if the component needs to be told to look up the field for information? Whatever it is, I've got no idea how to make it happen - any advice would be much appreciated.
Thanks
Having trouble editing some Visualforce code. I'm trying to edit the AccountHierarchyTree component from the Inline Account Hierarchy Visualforce page (https://appexchange.salesforce.com/listingDetail?listingId=a0N300000016chCEAQ) so it shows a custom Account field, but I get a "Content cannot be displayed: SObject row was retrieved via SOQL without querying the requested field: Account.Project__c" error. Edited section of code:
<!-- Include the following if you uses sites with accounts -->
<apex:outputText style="{!IF(pos.currentNode,'font-weight: bold;','')}" value=", {!pos.account.Type}" rendered="{!IF(pos.account.Type != '', true, false)}"/>
<apex:outputText style="{!IF(pos.currentNode,'font-weight: bold;','')}" value=", {!pos.account.Name}" rendered="{!IF(pos.account.Name!= '', true, false)}"/>
<apex:outputText style="{!IF(pos.currentNode,'font-weight: bold;','')}" value=", {!pos.account.Industry}" rendered="{!IF(pos.account.Industry!= '', true, false)}"/>
<!-- Stop -->
If I change account.Project__c to account.Name, Industry, or Type it works fine; all other fields I've tested don't.
Wondering if the component needs to be told to look up the field for information? Whatever it is, I've got no idea how to make it happen - any advice would be much appreciated.
Thanks
and send me the code..
--
Thanks,
Prashant
All Answers
You need to add the Project__c in the query..
--
Thanks,
Prashant
Sorry, I copied and pasted the code after modifying it for another edit / test; it still throws the same error message up when it is:
<!-- Include the following if you uses sites with accounts -->
<apex:outputText style="{!IF(pos.currentNode,'font-weight: bold;','')}" value=", {!pos.account.Type}" rendered="{!IF(pos.account.Type != '', true, false)}"/>
<apex:outputText style="{!IF(pos.currentNode,'font-weight: bold;','')}" value=", {!pos.account.Project__c}" rendered="{!IF(pos.account.Project__c!= '', true, false)}"/>
<apex:outputText style="{!IF(pos.currentNode,'font-weight: bold;','')}" value=", {!pos.account.Industry}" rendered="{!IF(pos.account.Industry!= '', true, false)}"/>
<!-- Stop -->
Or have I misunderstood your suggestion?
Regards,
John
or you can just me class will update for you..
--
Thanks,
Prashant
<apex:component Controller="AccountStructure">
<apex:attribute name="value" type="String" description="TODO: Describe me"/>
<apex:attribute name="currentId" description="This is the Account Id for displaying Acccount Hierarchy" type="String" required="true" assignTo="{!currentId}"/>
<div class="treeNode">
<apex:repeat value="{!ObjectStructure}" var="pos" >
<apex:repeat value="{!pos.levelFlag}" var="flag" first="0">
<apex:image url="/img/tree/empty.gif" height="16" width="20" rendered="{!IF(flag,false,true)}"/>
<apex:image url="/s.gif" alt="" width="3" height="16" rendered="{!IF(flag,true,false)}"/>
<apex:image url="/img/tree/chain.gif" height="16" width="20" rendered="{!IF(flag,true,false)}"/>
</apex:repeat>
<span height="16" v="top">
<apex:outputText rendered="{!IF(pos.nodeType=='start',true,false)}">
<apex:image id="tree_start" url="/img/tree/minusStart.gif" height="16" width="20" title="Click to expand/collapse nested items." onClick="TreeNodeElement.prototype.toggle(this,'{!pos.nodeId}')"/>
<apex:image id="Icon_start" url="/img/icon/custom51_100/globe16.png" width="16" height="16" rendered="{!IF(pos.currentNode,false,true)}"/>
<apex:image id="Icon_start_current" url="/img/icon/star16.png" width="16" height="16" rendered="{!IF(pos.currentNode,true,false)}"/>
</apex:outputText>
<apex:outputText rendered="{!IF(OR(pos.nodeType=='parent',pos.nodeType=='parent_end'),true,false)}">
<apex:image id="Tree_parent" url="/img/tree/minus.gif" rendered="{!IF(pos.nodeType=='parent',true,false)}" height="16" width="20" title="Click to expand/collapse nested items." onClick="TreeNodeElement.prototype.toggle(this,'{!pos.nodeId}')"/>
<apex:image id="Tree_parent_end" url="/img/tree/minusEnd.gif" rendered="{!IF(pos.nodeType=='parent_end',true,false)}" height="16" width="20" title="Click to expand/collapse nested items." onClick="TreeNodeElement.prototype.toggle(this,'{!pos.nodeId}')"/>
<apex:image id="Icon_parent" url="/img/icon/factory16.png" width="16" height="16" rendered="{!IF(pos.currentNode,false,true)}"/>
<apex:image id="Icon_parent_current" url="/img/icon/star16.png" width="16" height="16" rendered="{!IF(pos.currentNode,true,false)}"/>
</apex:outputText>
<apex:outputText rendered="{!IF(OR(pos.nodeType=='child',pos.nodeType=='child_end'),true,false)}">
<apex:image id="Tree_child" url="/img/tree/node.gif" rendered="{!IF(pos.nodeType=='child',true,false)}" height="16" width="20" title="Click to expand/collapse nested items." onClick="TreeNodeElement.prototype.toggle(this,'{!pos.nodeId}')"/>
<apex:image id="Tree_child_current" url="/img/tree/nodeEnd.gif" rendered="{!IF(pos.nodeType=='child_end',true,false)}" height="16" width="20" title="Click to expand/collapse nested items." onClick="TreeNodeElement.prototype.toggle(this,'{!pos.nodeId}')"/>
<apex:image id="Icon_child" url="/img/icon/desk16.png" width="16" height="16" rendered="{!IF(pos.currentNode,false,true)}"/>
<apex:image id="Icon_child_current" url="/img/icon/star16.png" width="16" height="16" rendered="{!IF(pos.currentNode,true,false)}"/>
</apex:outputText>
<apex:outputText rendered="{!IF(pos.nodeType=='end',true,false)}">
<apex:image id="Tree_end" url="/img/tree/nodeEnd.gif" height="16" width="20"/>
<apex:image id="Icon_end" url="/img/icon/desk16.png" width="16" height="16" rendered="{!IF(pos.currentNode,false,true)}"/>
<apex:image id="Icon_end_current" url="/img/icon/star16.png" width="16" height="16" rendered="{!IF(pos.currentNode,true,false)}"/>
</apex:outputText>
<!-- Change Below -->
<apex:outputLink value="/{!pos.account.id}" style="{!IF(pos.currentNode,'font-weight: bold;','')}" styleClass="columnHeadActiveBlack" target="_top">{!pos.account.name}</apex:outputLink>
<!-- Include the following if you uses sites with accounts -->
<apex:outputText style="{!IF(pos.currentNode,'font-weight: bold;','')}" value=", {!pos.account.Type}" rendered="{!IF(pos.account.Type != '', true, false)}"/>
<apex:outputText style="{!IF(pos.currentNode,'font-weight: bold;','')}" value=", {!pos.account.Project__c}" rendered="{!IF(pos.account.Project__c!= '', true, false)}"/>
<apex:outputText style="{!IF(pos.currentNode,'font-weight: bold;','')}" value=", {!pos.account.Industry}" rendered="{!IF(pos.account.Industry!= '', true, false)}"/>
<!-- Stop -->
</span>
<div> </div>
<apex:outputText rendered="{!IF(OR(pos.nodeType=='child_end',pos.nodeType=='child'),false,true)}">
<div id='{!pos.nodeId}'>
</apex:outputText>
<apex:outputText rendered="{!IF(OR(pos.nodeType=='child_end',pos.nodeType=='child'),true,false)}">
<div id='{!pos.nodeId}'><apex:image url="/s.gif" alt="" width="1" height="1"/></div>
</apex:outputText>
<apex:repeat value="{!pos.closeFlag}" var="close">
</div>
</apex:repeat>
</apex:repeat>
<br/><br/><br/>
</div>
</apex:component>
Thanks for your help - this is the first time I've played with Visualforce and my coding skills are poor, so apologies if I'm asking stupid questions!
and send me the code..
--
Thanks,
Prashant
Thanks again - the page loads fine when it is part of a standard account page layout:
However, I get an error code when I try clicking on the preview button on the Visualforce Pages Developer page: "Assertion Failed: sObject ID must be provided: Same value: null."
Any ideas?
TVM,
John
You need to project the object ID..that means just don't preview the page try to view with an associated object.
--
Thanks,
Prashant
Thanks,
John
I belive "head office, Goulburn, BSW, Gov ,other" is an account so this record id you need to pass while you are previewing the page..
Currently the code loads fine when it is part of the existing page:
However, I also want to be able to view the same information on it's own page, like you can using the existing view hierarchy link:
If I go to the Develop Visualforce Pages page there is a preview link:
But the page that loads gets this error:
If I understand things correctly the current code will only work when it is loaded in an actual account page, as it is getting the Account ID from that page:
How do I edit this code so if I am on the "Top Level" account page and click a link to open the Visualforce page in it's own tab, the Visualforce page will pull the Account ID from the "Top Level" account page?
Regards,
John
In the first image, you are able to view the result because it is tied to an account whereas in the second image it is not tied to any account and that resulting an error message.
Hope this is clear now and please select the best answer to close this thread.
--
Thanks,
Prashant
"...in the second image it is not tied to any account and that resulting an error message." Yes, I gethered that - what I'm asking is, how do I tie it to an account when I load the code in a new tab?
Regards,
John