I'm building a VF page to update 2 objects at the same time. Using Stack Force I was able to figure out how to build a VF page with an extension and now need to figure out how to get the parent record to show on the VF page.
Here is what I have.
Apex Class
public with sharing class SaveExtension
{
ApexPages.StandardController sc;
public AVTRRT__Job__c objBJob {get; set;}
public SaveExtension(ApexPages.StandardController sc)
{
this.sc = sc;
objBJob = new AVTRRT__Job__c();
}
public ApexPages.PageReference SaveBoth()
{
insert objBJob;
return sc.Save();
}
}
Visualforce Page
<apex:page StandardController="AVTRRT__Job_Applicant__c" extensions="SaveExtension">
<apex:form >
<apex:pageblock mode="edit">
<apex:inputField value="{!AVTRRT__Job_Applicant__c.AVTRRT__Stage__c}" />
<apex:inputField value="{!objBJob.Job_Type__c}" />
<apex:CommandButton action="{!saveboth}" value="Save"/>
</apex:pageblock>
</apex:form>
</apex:page>
I call the vf page by passing the Child ID in the URL and when saved this record is updated.
https://c.cs10.visual.force.com/apex/Update_Job_and_Job_App_w_Extension?ID=a0DJ000000FlalG
The object in the extension AVTRRT__Job__c ObjBJob is the parent of the object in the standard controller. The key is I want to be able to allow the user to make changes to the parent record (Job Order) when they are making updates on the child (Applicants).
Any code examples are appreciated.
Thanks, Ed