You need to sign in to do that
Don't have an account?
BrandonL
Custom button to pull object records to a custom object
Hello all,
First, I will describe the objects I'm working with.
Custom Object (EDS)
Custom Object (Plans)
Standard Object - Opportunity
We have the EDS and Plans objects master detailed to the Opportunity object and a lookup relationship between Plans and EDS. I am attemping to build a button on the EDS object for the lookup to Plans so when a user clicks the button, all the Plans related to the opportunity will pull into the EDS related list. Has anyone worked on a similar project or know if this is even possible? Please advise if any more info is needed, thanks!
First, I will describe the objects I'm working with.
Custom Object (EDS)
Custom Object (Plans)
Standard Object - Opportunity
We have the EDS and Plans objects master detailed to the Opportunity object and a lookup relationship between Plans and EDS. I am attemping to build a button on the EDS object for the lookup to Plans so when a user clicks the button, all the Plans related to the opportunity will pull into the EDS related list. Has anyone worked on a similar project or know if this is even possible? Please advise if any more info is needed, thanks!
What you would need is:
- A Visualforce page, which uses the EDS object as a standard controller
- An Apex class as an extension controller.
- The class would read the current EDS record, and then query for the Opportunity and related Plans records.
- After querying for the plans records, it would update the lookup field(s).
The VF page either could be a simple form with a save button, or use the action attribute of <apex:page> to redirect back to the EDS detail page.For more info, see here: http://andyinthecloud.com/2013/07/16/how-to-call-apex-code-from-a-custom-button/
You can create a Detail page button with execute Javascript option and put following code to execute the method from you class where you can perform any operation you want.
Code on execute javascript button -
{!REQUIRESCRIPT("/soap/ajax/32.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/32.0/apex.js")}
sforce.apex.execute("YourClassName","YourMethodName",{});
Code for you class -
global class YourClassName{
webservice static void YourMethodName(){
// operation which you want to perform
}
}
for step by step tutorial please refer -http://blog.shivanathd.com/2014/07/call-apex-class-from-custom-button-salesforce.html
Regards,
Vivek Patel.
Please like or mark as best answer if this answers you query to help others find the correct answer and improve the quality on the developer forum.