+ Start a Discussion
SFDC n12SFDC n12 

Id value 00511000000xQ80 is not valid for the Account standard controller

Hi,

I am trying to add a visualforce page as a home page component , and display it as a link in my home page , but wen i click on the link on the home page , it tries to open in a new window and displays the following error message,

" Id value 00511000000xQ80 is not valid for the Account standard controller "

Do i need to call this home page component in my VF Page , kindly help me on this issue.

Thanks in Advance
Sonam_SFDCSonam_SFDC
Id starting with 005 looks like a userID and not an Account ID..does the component contain Account information for a particular account you are trying to open?
SFDC n12SFDC n12
Hi,

I am trying to open a specific report based on the currently logged in user 's emp id.. The component contain the Viualforce page i used, below is my code,

VF PAGE : (This is the page i used in my home page component)

<apex:page standardController="Account" extensions="AF_AccountExtension">
<apex:form >
   
    <apex:pageBlock id="exRepTable">
        <apex:pageBlockTable value="{!exRepList}" var="exRep">
       
            <apex:column headerValue="Name">
                <apex:outputLink value="/{!exRep.Id}" target="_blank">{!exRep.Name}</apex:outputLink>
            </apex:column>
            <apex:column headerValue="Report Description" value="{!exRep.Short_Description__c}"/>
            <apex:column headerValue="Primary Contact" value="{!exRep.Primary_Contact__c}"/>
           
            <apex:column headerValue="Action">
                <apex:commandLink target="_blank" value="Generate Report" action="{!generateReport}" styleClass="btn" style="color:Black;text-decoration:none">
                    <apex:param name="repLink" value="{!exRep.Report_Link__c}" assignTo="{!repLink}"/>
                    <apex:param name="acPDN" value="{!accnt.Ally_Primary_Dealer_Number__c}" assignTo="{!acPDN}"/>
                    <apex:param name="repName" value="{!exRep.Id}" assignTo="{!repName}"/>
                    <apex:param name="storageLocation" value="{!exRep.Storage_Location__c}" assignTo="{!storageLocation}"/>
                    <apex:param name="FileName" value="{!exRep.FileNameFilter__c}" assignTo="{!FileName}"/>
                </apex:commandLink>
            </apex:column>
           
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:form>
</apex:page>

Controller :

public class AF_AccountExtension
{
    public Account ac{get;set;}
    public ApexPages.StandardController controller{get; set;}
    public List<Account> acList{get; set;}
    private String acId;
    private String contUrl='';
    private String opType='';
    private String opName='';
    private String ownerId='';
    private String recordTypeId='';
    private String userObj='';
   
    //External Reports
    public List<External_Reports__c> exRepList{get; set;}
    public String repLink{get; set;}
    public String acPDN{get; set;}
    public Account accnt{get; set;}
    public String repName{get;set;}
    public String storageLocation{get; set;}
    public String fileNameFilter{get;set;}
      

    /**
    **
    **/   
    public AF_AccountExtension(ApexPages.StandardController controller)
    {
        acId = ApexPages.currentPage().getParameters().get('acId');
        contUrl = ApexPages.currentPage().getParameters().get('newUrl');
        opType = ApexPages.currentPage().getParameters().get('opType');
           
        this.controller = controller;
        ac = (Account)controller.getRecord();
        accnt = [Select Ally_Primary_Dealer_Number__c from Account where Id=:ac.Id];
        exRepList = [Select Name,Report_Link__c,Short_Description__c,Primary_Contact__c,Storage_Location__c,FileNameFilter__c from External_Reports__c Where isActive__c = true AND FileNameFilter__c = 'PDN'];
    }
   
    /**
    **
    **/   
   
    public PageReference getNearByAccounts()
    {
        ac = [Select Name,ShippingLatitude,ShippingLongitude from Account where Id = :acId];
       
        try
        {
            acList = AF_DealerCRM_HelperClass.getNearByAccounts(ac.ShippingLatitude,ac.ShippingLongitude);
        }
        catch(Exception e)
        {
            System.debug('Query Exception'+e.getMessage());
        }
        return null;
    }

    /**
    **
    **/   
   
    public pageReference navigateToAccount()
    {
       PageReference pg = new PageReference('/'+acId);
       pg.setRedirect(true);
       return pg;
    }

    /**
    **
    **/   
   
    public pageReference contOpp()
    {  
        String finalUrl = ApexPages.currentPage().getHeaders().get('Host');
        system.debug('finalUrl****'+finalUrl);
       
        if(opType == 'Retail' || opType == 'Remarketing/SmartAuction' || opType == 'Insurance')
        {  
            finalUrl = 'https://'+finalUrl.substring(2,6)+'.salesforce.com'+contUrl;
        }
        else if(opType == 'Loans' || opType == 'Wholesale/Floorplan' || opType == 'contact' || opType == 'threat' || opType == 'ci' || opType == 'activity' || opType == 'case')
        {
            finalUrl = contUrl;
        }
        PageReference pg = new PageReference(finalUrl);
        return pg;
    }

    /**
    **
    **/  

    public PageReference generateReport() {
  
        PageReference pg = null;        
        String userId = UserInfo.getUserId();
        User usr = AF_DealerCRM_Utility.getUserInfo(userId);
       
        if (repLink != null && acPDN != null) {
           System.debug ('storage location : ' + storageLocation);
           if (storageLocation  == 'Cognos' && fileNameFilter == 'PDN'){
              repLink += '&p_p_PDN=' + acPDN;
            }
            else if (storageLocation == 'Cognos' && fileNameFilter == 'Employee Number')
            {
             repLink +=  '/' + usr.EmployeeNumber +'.pdf';
             }
                 else if (storageLocation == 'Cognos' && fileNameFilter == 'Employee HR ID')
                 {
                     repLink +=  '/' + usr.Employee_HR_ID__c +'.pdf';
                    
           
            }

           
           
            if (storageLocation == 'Teamroom' && fileNameFilter == 'PDN') {
              repLink += '/' + acPDN + '.pdf';
            }
            else if (storageLocation == 'Teamroom' && fileNameFilter == 'Employee Number')
            {
             repLink +=  '/' + usr.EmployeeNumber +'.pdf';
             }
                 else if (storageLocation == 'Teamroom' && fileNameFilter == 'Employee HR ID')
                 {
                     repLink +=  '/' + usr.Employee_HR_ID__c +'.pdf';
                    
           
            }
          
        }
        
        System.debug ('Link url : ' + repLink);
         
        External_Reports_Log__c er = new External_Reports_Log__c(Report_Name__c = repName,User__c = UserInfo.getUserId(),Report_generated_time__c = System.now());
        List<External_Reports_Log__c> extRepLogList = new List <External_Reports_Log__c>();
        extRepLogList.add (er);
           
        try {
            AF_DealerCRM_DML_Utility.insert_op (extRepLogList);
        }
        catch (system.DMLException e) {
            System.debug ('DML Exception'+e.getDMLMessage(0));
            return null;   
        }
        pg = new PageReference(repLink);
        
        return pg;
   }

}

Thanks
Chidambar ReddyChidambar Reddy
Hi Bharath,

You might be accessing a visualforce page from a User detail page which should be accessed from account detail page.

In this case you need to change the visualforce page to handle this error.


Another issue is you might be passing UserId as a id parameter in the custom link you created.


SFDC n12SFDC n12
Hi,

I have just called the VF Page in my custom link , please guide me what should i change in my VF code

Thanks
Chidambar ReddyChidambar Reddy
You should change it from standard controller to custom controller if you want to use it from the home page component


How were you specifying the account based on logged in user??
Please consider that too.
Vinit_KumarVinit_Kumar
Can you post the URL of your custom link as how you are trying to access that VF page ??
SFDC n12SFDC n12
I have just called my visualforce page direclty in my custom link, i have not used any url in my custom link , all logic applies in my vf and controller only
Vinit_KumarVinit_Kumar
where are you using this link on which object detail page ??
SFDC n12SFDC n12
on Account object
nbknbk
From which link you executed this page and causing the error (is it generateReport)
SFDC n12SFDC n12
yes, thats correct 
Vinit_KumarVinit_Kumar
Ok, so I looked into this issue and found when creating a VF page link on Home page,salesforce is appending logged in UserId as ?id=<logged in User Id> with the VF page URL.

Not sure what is the reason behind,you should check with salesforce support to get an answer for this.

To workaround this issue,while creating the custom Link use Execute Javascript option in Content Source and use the below code to create the link 

window.open("/apex/yourpage")

and then Save the link.

This should work for you !!
nbknbk
Try with following code in constructor.
Make the acId variable as static. I hope the accountid is setting with blank after page refresh.
public AF_AccountExtension(ApexPages.StandardController controller)
    {
        //acId = ApexPages.currentPage().getParameters().get('acId');
          acId = '001*******' ; //for trial end error hard code the account id value and check if it is working correclty then you will pass the accountid if it is BLANK
    }
Tejpal KumawatTejpal Kumawat
Hello Bharath,

In Home Page component, replace your link like
<Instance of  your org>/apex/<Page Name>?id=<Account Id>

Example of url : https://c.ap1.visual.force.com/apex/HelloWorld?id=0019000000MI7lW

Thanks
Tejpal