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

Saving Lookup object fields from main form



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%; }

<apex:form id="incidentForm">

<TR >
<TD colspan="2"><apex:inputField value="{!DoDEA_Serious_Incident_Report__c.Other_Incidents__c}"></apex:inputField></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>
<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>
<apex:commandButton value="Save" action="{!Save}"/>






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)


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');
return cancelClicked;