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

Facing Problem to Override the Standard "New" Button functionality

Hi All,


I have two object. First one is standard object"object A" and Second one is custom object "object B". Both object have a parent-child relationship. Object A is parent and Object B is child. I have a standard "New" button on custom object "object B".


I want to override the New button functionality. if anyone will try to create the "object B" by  "New" button directly then he can't do this. We can only create the "object B" through the "object A". In "object A", there is one button for "object B". So only by this button anyone can create the object B.


For this purpose i am trying to override the New button functionality of "Object B" by VF page and JavaScript but i am not getting any solution because in every case URL is repeting so my loop is not checking condition.


Please help me to findout the solution ASAP. Thanks in advance!





Don't  use java script. Create a Apex Class with VF page and on the action tag of VF page just write the coding of new buttion like this. Suppose if you want to Overwrite New Button Add the code like this



public Pagereference RedirectToPREClonePage()

//For Production
PageReference MainPage;
        MainPage= new PageReference('/'+RecordId+'/e?clone=1&00N600000022qqR=&CF00N600000022qpO_lkid=&CF00N600000022qpO=&CF00N600000022qpO_lkold=&00N600000022qpJ=&CF00N600000022qpT_lkold=&CF00N600000022qpT_lkid=&CF00N600000022qpT=&00N600000022qql=&00N600000022qqv=&00N600000022qr5=&00N600000022qre=&00N600000022qro=&00N600000022qpE=&00N600000022qp9=&'+CloneFieldId+'='+RecordId+'&retURL=%2F'+RecordId);
        MainPage.getParameters().put('nooverride', '1');
return MainPage;
Please let me know if you face any issue. 



Thanks for your help But sorry to say i am not getting any solution by this method.


when i am trying to matching RecordId and CloneId, i am getting URL no longer exist.  each and every time its directing to the "MainPage.getParameters().put('nooverride', '1')". Does matter when i am clicking form "Object B" directly or by "Object A".



Try To Create your own URL almost look like the Standard URL.


If you are from India You can Call me At my Number for Discussion : +91-9899464350


I have done with Sample code also but i did not get any satisfactory solution. it's not working according my requirement. Thanks!