You need to sign in to do that
Don't have an account?
Frank Jordan
How to link Visualforce button to custom detail page button
I have the following class and visualforce page created, so when the button is pressed, the record owner is updated. I would like to add this button to the detail page like the button below. Can anyone help?
Class:
VF Page:
Class:
public class classSubmitToLegal { public Agreement_Request__c a{get;set;} public classSubmitToLegal() { a = new Agreement_Request__c (); a = [select Business_Unit__c from Agreement_Request__c Where Id=: ApexPages.currentPage().getParameters().get('Id')]; } public void someMethod() { if(a.Business_Unit__c == 'EIS') { a.OwnerID ='00G18000000ZRlS'; update a; Apexpages.Message errorMessage = new Apexpages.Message(ApexPages.Severity.Info,'You have changed the owner'); Apexpages.addMessage(errorMessage); } else { Apexpages.Message errorMessage = new Apexpages.Message(ApexPages.Severity.Info,'You cannot update'); Apexpages.addMessage(errorMessage); } } }
VF Page:
<apex:page controller="classSubmitToLegal"> <apex:form> <apex:commandButton action="{!someMethod}" value="Submit To Legal" id="Submit_to_Legal__c"/> </apex:form> </apex:page>
You can do it via two ways :
1. Creating a custom button and calling Visualforce page. Please go here (https://developer.salesforce.com/docs/atlas.en-us.workbook_vf.meta/workbook_vf/overrides_3.htm)
2.
Hope this helps,
--
Thanks,
Swayam