You need to sign in to do that
Don't have an account?

Saving two objects from one VF page?
I'm trying to streamline data entry for my organization. We've got two objects that could be improved by a visualforce page that's cut down to just the fields used by the data entry team. It would be even better if we could get the Save button on that page to save the two objects that get created from that. The objects in question are a Contact and a custom object that points to the new contact.
I'm currently using a controller extension to save a contact and redirect the user back to the data entry page when the Save button gets pressed. I'm thinking I need to do something like getting the ID of the contact I've just saved and then maybe call a custom controller for the custom object. Is it possible to call a custom controller for another object from a controller extension?
Can anyone point me to examples of how to do something like this?
Thanks!
Thanks for setting me on the right track.
There's some details missing from the original response, so here's stripped-down version of my current code. It also sets the record type of the contact and redirects the user back to an edit page when done.
All Answers
in your Extension Method, override the save() function, basically just create your own save function, in this function save your Contact. After you inserted your contact, the original reference gets populated with the id.
Thanks for setting me on the right track.
There's some details missing from the original response, so here's stripped-down version of my current code. It also sets the record type of the contact and redirects the user back to an edit page when done.