I have created a Visualforce Page and put it in the Account Layout, the Related Tab, at the end of the page.

  1. Within the Setup environment, I have enabled all profiles to access the page.
  2. I have enabled these options for the page:
    • Available for Lightning Experience
    • Lightning Communities
    • mobile app

I am able to see the page within the view, but other people within the organisation are not.


I have researched a bit. My VF page is basically a table which renders if it finds the current Account AccountNumber (stored in myHiddenField), passes this one to myHiddenField_002 and then to controller:

<apex:form >
<!-- Hidden field to store the Account.AccountNumber value -->
<apex:outputPanel title="Subscription List 00" id="subscriptions_list_00" style="display:none">
    <apex:pageBlock id="selectPub0">
        <apex:commandButton value="{!Account.AccountNumber}" id="myHiddenField" rerender="subscriptions_list_01" >
            <apex:param name="AccountNumber" value="{!Account.AccountNumber}" assignTo="{!AccountNumber}"/>

<apex:outputPanel title="Subscription List 007" id="subscriptions_list_007" style="display:none">
    <apex:pageBlock id="selectPub007">
        <!-- Hidden field to store a new value of the variable -->
        <apex:inputHidden value="{!AccountNumber}" id="myHiddenField_002" />
        <!-- Action function for the rerendering -->
        <apex:actionFunction name="passStringToController" action="{!ReturnAccountNumber}" rerender="subscriptions_list_01"/>

The button just holds the value within the myHiddenField. So, on document ready, I have a javascript:

$(document).ready(function() {
    $.when( document.getElementById("myHiddenField") != null ).done(function( x ) {
        var param = jQuery('[id$=myHiddenField]').val();


public String AccountNumber{get;set;}
public void ReturnAccountNumber(){
 system.debug('AccountNumber' + AccountNumber);

and then perform some soql queries using AccountNumber var.

So, the whole page would not work if there isnt't a value for myHiddenField, myHiddenField_002 or AccountNumber var.

Interestingly enough, I could see values for Account.AccountNumber within the button and also in the developers console. Others can too. Problem must occur afterwards in myHiddenField_002 or in the controller function. I am stuck now and would appreciate any ideas

  • 1
    Do they see something else? – Adrian Larson Feb 19 '18 at 23:05
  • @adrian Please, see edit – mirantii Feb 19 '18 at 23:50
  • You didn't really answer @AdrianLarson's question. What exactly do other users see? An error? A blank space? A completely different page layout? – David Reed Feb 20 '18 at 0:10
  • Also, why are you jumping through these hoops to get the account number? Just use the Id and perform a SOQL query to get the account details. – David Reed Feb 20 '18 at 0:12
  • @DavidReed Sorry, other users see a blank table, but do see a value for myHiddenField, when I disbled the style. The reason behind doing these hoops is because I need to make a join query on few different custom objects based on the current accound id only. I couldn't think of another possible way to find the current id, bacause we now don't have a field to match to the other objects, apart from Account. – mirantii Feb 20 '18 at 0:19

Your data flow does not make sense. You don't need to use jQuery and hidden fields to get details of the Account on whose page layout you're embedded.

All you need to do is write a simple Visualforce controller extension and get access to the Account's Id, AccountNumber, etc, via the standard controller. You can then perform SOQL based on the Account Id, or use a parent-child query, to get the details of the custom objects you want to display.

  • Thank you very much, this was extremely helpful, although it might have been obvious to you – mirantii Feb 20 '18 at 1:17
  • I'm happy to help! – David Reed Feb 20 '18 at 1:42

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.