function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
newbiembanewbiemba 

Saving Lookup object fields from main form

Hello,

 

I have a custom object with a lookup field to another custom object. Now using one for in visualforce i want to save data to both of these objects.My issue is I cant retrieve any calue of the lookup object fields in my controller class or even save from my vf page.

 

Code is below

vf page

<apex:page standardController="Incident_Report__c" tabstyle="account" standardStylesheets="false" sidebar="false" extensions="IncidentReportController" >

<style type="text/css">
.inputTextBig { width: 80%; }
.inputTextWidthMedium { width: 25%; }
.inputTextWidthMediumSchool { width: 20%; }
</style>

<apex:form id="incidentForm">
<br></br>
<TABLE>

<TR >
<TD colspan="2"><apex:inputField value="{!DoDEA_Serious_Incident_Report__c.Other_Incidents__c}"></apex:inputField></TD>
</TR>
<TR>
<td>

<!-- this is the lookup field data which I want to save in database ot at least access in apex controller so that I can save it there-->
<TABLE cols="5" align="LEFT" WIDTH="100%">
<TR style="font-style:bold;">
<TD>PARTICIPANTS(List name as last, first,MI) </TD><TD>GENDER </TD><TD>AGE </TD><TD>GRADE </TD><TD>STATUS </TD>
</TR>
<TR>
<TD><apex:inputField value="{!Incident_Report__c.Incident_Report_Participants__r.Last_Name__c}"></apex:inputField><apex:inputField value="{!Incident_Report__c.Incident_Report_Participants__r.First_Name__c}" ></apex:inputField><apex:inputField value="{!Incident_Report__c.Incident_Report_Participants__r.MI_Name__c}" ></apex:inputField> </TD></TD>
</TR>
</TABLE>
</td>
</TR>
<apex:commandButton value="Save" action="{!Save}"/>

</TABLE>

</apex:form>

</apex:page>

 

Controller

public with sharing class IncidentReportController {
public PageReference refresh= new PageReference(ApexPages.currentPage().getUrl());
public Incident_Report__c VisRecord;
public Incident_Report_Participants__c Participants;
public IncidentReportController(ApexPages.StandardController controller)
{
System.debug('eeee~~~~~~~~~~~~~------'+controller.getRecord());
VisRecord=(Incident_Report__c)controller.getRecord();
VisRecord.Date_and_Time__c= System.now();//Date.today();

}

public PageReference save()
{
System.debug('~THIS IS NULL~~~~~~~~~~~~------'+VisRecord.Incident_Report_Participants__r.Last_Name__c);
//upsert visRecord;
PageReference cancelClicked=new PageReference('/home/home.jsp');
cancelClicked.setRedirect(false);
return cancelClicked;


}

 

 

Thanks