0

I'm currently building out a custom VisualForce page that will have two sections:

Upper Block: Contains 3 input fields that would be used in a SOQL query to render children records in the lower block. It will also contain a Decimal field for entering in a "Payment" amount.

Lower Block: Will display all Invoice records that are associated with the aforementioned 3 input fields. The related list will display field detail from each Invoice record.

I'm trying to add an additional column to the related list, which would also be a Decimal data type (Application Amount). This field does not exist on the Invoice object currently. Basically I'm trying to add a decimal input field as a column in the related list results, so end-users can input a payment amount for each invoice. I would then use those inputs for apex controller logic (going to create payment records upon save.

Can anyone please recommend the right approach here? Not sure which tags should be used or if anyone can provide an example to get me started. Added a mock-up for additional detail.

Thanks!

1 Answer 1

1

Use a wrapper class. Basically, a class which mimics your object, but adds extra information.

public class WrapperClass {

    public sObject Record { get; set; }
    public Decimal Field { get; set; } 

    public WrapperClass(sObject record) {
        this.Record = record; 
    }
}

Create a list of wrappers using your data, then display the data on your page, with that extra field:

<apex:repeat var="wrapper" value="{!wrappers}">
    <apex:column value="{!wrapper.Record.Name}" />
    <apex:column value="{!wrapper.Field}" /> 
</apex:repeat>
1
  • Awesome, thanks @battery.cord!
    – Tom Kline
    Commented Mar 20, 2018 at 18:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .