You need to sign in to do that
Don't have an account?
rossco
Overriding New Button for Custom Object
Hi I have a custom object (credit agreement) that has a lookup relationship to the Opportunity. I want to override the New button (for credit agreements) and retrieve values from the parental Opportunity. I have written a VF page that has a standard controller of the creditagreement__c and has extensions but in the extensions class I cannot seem to access the opportunity data. Help ! :) Many thanks to all in advance Ross
Hi,
You can pass the id of opportunity to which creditagreement__c record is associated with while calling you VF page through the Custom Button as paramether like below:
/apex/yourVFPageName?id={! creditagreement__c.opportunity__c}
Now you can easily retrieve this value by using ApexPages.currentPage().getParameters().get(‘id’).
Id ids= ApexPages.currentPage().getParameters().get(‘id’);
Now you the id of opportunity make the query on opportunity object by using this id.
Opportunity op=[select id, other fields that you want from opportunity where id=:ids];
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
Thanks for the response.
Yes, this will work for a custom button, button I want to override the standard "New" button.
Ross
I'm not sure you'll be able to do this via an override of the new button. The thing is that the new button appears in a number of places - at the top of a list view for example. At that point, there isn't an opportunity associated with the record, so if your override relies on one it won't work.