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
Kiran456Kiran456 

Adding button to standard layout

I have a button create patient on standard layout which is supposed to excecute some logic and take user to the detail page of patient record. I have extended standard controller and added that button on the page but when I click on that button a new page is opens. I dont want to open a new page. I want that after executing controllers logic. It should take user to the detail page of newly created patient without opening any blank page initially. Any pointers would be of great help. Thanks in advance.

Prafull G.Prafull G.
You should call a VF page on the button click and call a action method to perform logic and redirect user to Detail page.

Example
VF Page:
<apex:page controller="MyController" action="{!redirectMe}">
</apex:page>

Controller:
public class MyController {

public pageReference redirectMe() {
// Perform your logic here
// and Redirect user to the requested page
}
}