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
qsdunnqsdunn 

Edit Master Object from Detail page

 I've got a custom object (Awards Attendance) which acts as a junction object between another custom object and Contacts. Essentially, it is used to track the bookings of specific individuals to certain events.

   

To keep them from having to flick backwards and forwards between pages, my users would like me to pull some information from the Contact record through to the page of the Awards Attendance record.

 If they just want to view the data, I can do this just fine with a text formula field on the Awards Attendance (and have set up a temporary solution which does just that).

 

 But (as the title of the post should suggest) I'm having difficulty enabling the editting of the Contact from the Awards Attendance page.

 

I created a page that looked a little like this:

 

<apex:page standardcontroller="Awards_Attendance__c">
<apex:form>
<apex:pageBlock title="Information From Contact Record" mode="inlineEdit" >
<apex:pageBlockButtons>
<apex:commandButton action="{!save}" value="Save" id="SaveButton" />
<apex:commandButton action="resetInlineEdit()" value="Cancel" id="CancelButton" />
</apex:pageBLockButtons>
<apex:inlineeditsupport showOnEdit="SaveButton,CancelButton" resetFunction="resetInlineEdit" />
<apex:pageBlockSection>
<apex:outputField value="{!Awards_Attendance__c.contact__r.access_requirements__c}" />
<apex:outputField value="{!Awards_Attendance__c.contact__r.dietary_requirements__c}" />
<apex:outputField value="{!Awards_Attendance__c.contact__r.specific_requirements__c}" />
</apex:pageBLockSection>
</apex:PageBlock>
</apex:form>
</apex:page>

 

and added it to the page layout for Awards Attendances.

But the "Save" button doesn't save any changes to the fields, instead discarding them a display the Awards Attendance page inside itself.

   

I attributed this to the fact that the "save" method being called was that of the standard controller for the Awards Attendance not the one for the Contact.

So I put this page in the Awards Attendance page layout:

 

<apex:page standardController="Awards_Attendance__c" action="{!URLFOR($Page.Contact_Requirements_Display,awards_attendance__c.contact__c,null,true)}" >
  <h1>Redirecting to <apex:outputField value="{!awards_attendance__c.contact__C}" />...</h1>
  Please wait.
 </apex:page>

 

which then redirects to this page:

 

<apex:page standardcontroller="Contact">
<apex:form>
<apex:pageBlock title="Information From Contact Record" mode="inlineEdit" >
<apex:pageBlockButtons>
<apex:commandButton action="{!save}" value="Save" id="SaveButton" />
<apex:commandButton action="resetInlineEdit()" value="Cancel" id="CancelButton" />
</apex:pageBLockButtons>
<apex:inlineeditsupport showOnEdit="SaveButton,CancelButton" resetFunction="resetInlineEdit" />
<apex:pageBlockSection>
<apex:outputField value="{!contact.access_requirements__c}" />
<apex:outputField value="{!contact.dietary_requirements__c}" />
<apex:outputField value="{!contact.specific_requirements__c}" />
</apex:pageBLockSection>
</apex:PageBlock>
</apex:form>
</apex:page>

 

But this doesn't work either. It looks it works (with the orange text of unsaved changes being replaced by the normal black when the "Save" button is clicked and nothing crazy happening) but the changes are not actually saved.

 

 

Does anyone see a way to fix this? Or another way to solve this problem which doesn't involve entirely remaking the Awards Attendance page in VIsualforce?

 

EDIT: I tried to put those code blocks in spoiler tags, for ease of readability, but the formatting kept going crazy when I tried to post it like that. Sorry, guys.

 

 

 

 

 

 

 

 

 

 

 

myforcedotcommyforcedotcom

The problem is that a standard controller will only handle the record for the controller, which in this case is your Awards_Attendance__c record.

 

What you can do is add an extension class to your page to handle retrieving and saving the Contact Record along with the Awards_Attendance__c record.

You will also need to write a custom "Save" Method instead of using the standard "save" method. This will allow you to save the Contact record and the Awards_Attendance__c record.