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
aKallNVaKallNV 

What does it take to Override the Edit button?

I have a cutom object that has many-to-many relationships with several other objects via a universal join object.  The object kind of works like the Task object...it's purpose is to allow our users to summarize their work for the day and then relate it all things that pertain to it, which could be one or many Contacts, Cases and Two Custom Objects. The object also has a look Up relation to the Account Object.  The VF page launches and works pretty well when they click a Custom button, which is just a Create New button  on the related list on the Account Detail page. The button passes the account id that the button was clicked from. I use the account id to query for all the various potential related records...for example all open cases that belong to that Account. I also use the passed id to create the relationship to the account in the Save Method.

 

Again, I have most of that working well, and now I am wondering what I need to do get the same functionality happening from the Edit button.  I am pretty novice, so I have little idea on where to start. I notice that the edit button automatically provides the record's id in the url, and that in overriding the edit button you are not allowed to pass any extra ids. So do I have to write a whole bunch more code to work with that id?

 

The class is already pretty long. So I am just going to post the first few lins so that you can see how I have set up my variables and constructor, and just below the constructor is the method that uses the account id.

public with sharing class narrativeWizard_Controller {
        
        public String accountID;
        public String swpnAccount { get; set; }
        public SchoolWorkPlanLog__c getLog { get; set; }
        public List<UniversalJoin__c> juncObs { get; set; }
        public List<cAIS> theWrappers { get; set; } 
        public Map<ID,List<cAIS>> theWrapperMap { get; set; }
        public List<DeployedStrategy__c> theDSs { get; set; }
        public List<Goal__c> theGoals { get; set; }
        public List<cGS> theGoalWrappers { get; set; }        
        public Set<String> unitOptions = new Set<String>();
        public String selectedUnit { get; set; }
        public Set<String> princyOptions = new Set<String>();
        public String selectedPrincy { get; set; }
        //public Set<String> catyOptions = new Set<String>();
        //public String selectedCaty { get; set; }
        public List<cCONS> theConWrappers { get; set; }
        public List<cCASES> theCaseWrappers { get; set; }
        public String unitFilter { get; set; }
        public Set<String> goalUnitOptions = new Set<String>();
        public String selectedGoalUnit { get; set; }
        
        
        //sets up class extension of SchoolWorkPlanLog__c
        private final SchoolWorkPlanLog__c swpn;
                
        //CONSTRUCTOR
        public narrativeWizard_Controller(ApexPages.StandardController swpnController) {
            this.accountID = ApexPages.currentPage().getParameters().get('aID');
            this.swpn = (SchoolWorkPlanLog__c)swpnController.getRecord();
            this.setUpAccount();  
            this.makesStrategyWrappers();
            this.makesGoalWrappers();
            this.makesContactWrappers();
            this.makesCaseWrappers(); 
            this.getLog= new SchoolWorkPlanLog__c();
            this.setUpUnitFilter();
            this.selectedUnit = setUpUnitFilter();
            this.selectedGoalUnit = setUpUnitFilter();
            this.getAllStrategyUnits();
            this.getStratyPrincys();
            this.getAllGoals();
        }
        
        //pulls the Account from which the Log was initiated.
        public void setUpAccount() {
            Account acct = [select ID, Name from Account where ID = :accountID Limit 1];
            this.swpnAccount = acct.Name;
        }