You need to sign in to do that
Don't have an account?
Urvik
Apex Help for Standard object
Hi,
I have "Address Information" in Contact object with Mailing Street, City, State, Zip and Country fields and I have an object called "Address History" that has a lookup relation with Contact object.
I would like an ability which by clicking a button blank out the Address fields in contact object and put the old address in the Address History object.
Any idea how could I accomplish this?
Thanks
Urvik,
You can create a custom button which would call a VF a page.On the page action attribute,you can call method in your controller which would perform your requirement.
How do I call the method? Any help would be appreciated.
Thanks,
Urvik
Urvik,
You can call method from action attribute of the <apex:page> tag.
I hope below example will help you.
//------------VisualForce Page--------//
<apex:page controller="MyController" action="{!updateAddressHistory}" >
<apex:page>
//-------------Apex Controller class--------------//
public class MyController {
public PageReference updateAddressHistory() {
//TODO: block of code to copy address from the contact to address history record
//TODO: block of code to set contact address blank
//TODO: block of code to redirect user to the calling view state
//return pagereference
}
}
Note:- Dont forget to mark this post as solution if it helps.
Thanks
Deshraj Kumawat
Agreed with Dehsraj,but with couple of mofication as you want to use it on standard object you will have to use standard controller on your VF page.Please go through the below code :-
Yes Vinit, I am with you but I dont think he need to use standard controller in this problem. I dont see any use of standard controller here.
Dehsraj,
Without the use of standard controller ,he won't be able to add the button to the Layout which is neede here :)
My bad, agreed !!!