function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Dea73Dea73 

Visualforce command button doesn not work with controller extension

Hi all,

 

Can someone help me figure this out please!!!

 

I have a master detail relationship between cases and a custom object called affected circuits.

Because of custom data display issues, i had to recreate the case view detail page as a visualforce page.

 

I manage to display affected circuits as a related list on the VF page.

Everything work fine, except the new button where you create a 'lineitem' in the affected circuits page.

 

below is the controller extension that i created, where i have a page refernce with the URL and parameters to go to the insertpage when the button is clicked.

 

Can anyone help me figure out why it's not working or is there anothe rway of doing this???

 

public with sharing class AffectedCircuitsExtension {
       
    
        private final Case afc;
       // private final Affected_Circuits__c cafc;
    
       
        public AffectedCircuitsExtension(ApexPages.StandardController stdController) {
   
    //Id id = ApexPages.currentPage().getParameters().get('id');
        this.afc = (Case)stdController.getRecord();
       
    }
   
   
   
 public Circuits__c[] getOffCircuits() {
   
   
    
    Circuits__c[] offnet = [Select Id, Circuit_ID__c
                            From Circuits__c
                            WHERE Supports_Customer_Circuit__c IN (Select Circuits__c                
                                                                   FROM Affected_Circuits__c
                                                                   WHERE Case__c = :afc.Id)
                           ORDER BY Id];
     return offnet;                              
           }
      
     public PageReference NewAffectedCircuits()
     {
        PageReference NewAFCPage = new

PageReference('/a0Y/e?CF00NQ0000000gCYj=afc.Id&CF00NQ0000000gCYj_lkid=afc.Id&retURL=%2Fafc.Id&saveURL=%2Fafc.Id');
        newAFCPage.setRedirect(true);
        return newAFCPage;
     
     }  

}

 

 

Thanks

Best Answer chosen by Admin (Salesforce Developers) 
Dea73Dea73

Thank God for Javascript.

Found someone else with almost the same problem, the solution is below:

 

<script>
      function newURL() {
         
          address = "/a0Y/e?CF00NQ0000000gCYj={!Case.CaseNumber}&CF00NQ0000000gCYj_lkid={!Case.Id}&retURL=%2F{!Case.Id}&saveURL=%2F{!Case.Id}";
          window.parent.location.href = address;
      }
   </script>