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
chris925chris925 

Summary data from master object doesn't populate on child screen

Hi, I've got a Master-Detail relationship between two custom objects, Transaction and Transaction Line Items.  I've created a VF page for Transaction Line Items in order to display some of the master Transactions fields read-only on the child page.  I've used the standard controller for Transaction Line Item, and overridden the New button to call my VF page instead.  So far, so good.

 

However, when I create a new Transaction Line Item record from a Transaction, the top portion of summary fields don't populate (which was the whole reason to create the VF page).  Here's my simple code - any pointers?  Thanks!

 

VF page:

<apex:page standardController="Transaction_Line_Item__c">
<apex:form >
<Apex:pageBlock title="Transaction info">
Transaction Date: {!Transaction_Line_Item__c.Financial_Transaction__r.Financial_Date__c}
<p></p>
Transaction Description: <apex:outputField value="{!Transaction_Line_Item__c.Financial_Transaction__r.Transaction_Description__c}"/>
<p></p>
Transaction Amount: <apex:outputField value="{!Transaction_Line_Item__c.Financial_Transaction__r.Financial_Amount__c}"/>
</apex:pageBlock>
<apex:pageBlock title="Enter a line item for this transaction:">
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Save"/>
</apex:pageBlockButtons>
Line Item Description: <apex:inputField value="{!Transaction_Line_Item__c.Line_Item_Description__c}" />
<p />
Line Item Amount: <apex:inputField value="{!Transaction_Line_Item__c.Line_Item_Amount__c}" />
</apex:pageBlock>
</apex:form>
</apex:page>

Jeff MayJeff May

The Master Summary fields won't update until after the Detail record is saved.  At that point, you'll need to requery the record to get the update.  Instead, it might be easier to keep a controller-variable for the Summary field and display that.   Set it on initial record load, then add/subtract as needed based on the TransactionLineItem being created/edited.

chris925chris925

"The Master Summary fields won't update until after the Detail record is saved."

 

Hmm, this is unfortunate.  The data in the master info already exists in the DB, and it's intended to be read-only on this page so it wouldn't need to re-save afterward - just looking for it to display on the page while the detail data is being entered.  Does your recommendation still stand given that?

Jeff MayJeff May

The Summary fields will have a value, as you say, but it won't be the right value.  If you just want "something" to display, you can create a formula field on a Contact (for instance), that references the Rollup Summary field from Account and place that on your page layout.