You need to sign in to do that
Don't have an account?
john.kr
There needs to be a Total that adds up all the invoice line items
In that one i am creating a Invoice pdf vf page in the page i want total amount of invoice line items.how to write for loop and this total amount value how to insert vf page what commponet is used.please give me reply
Hi,
You can use the following code for the reference in your Apex class of the VF page
list<invoice> invoiclist=[select amount from invoice];
integer sum=0;
if(invoiclist.size()>0)
{
for(invoice inv:invoiclist)
{
if(inv.amount!=null)
{
sum=sum+inv.amount;
}
}
}
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
How to add this list information in visualforce page? which component is used
Hi,
Hi,
If you want to display the list information on the page you can either <apex:pageblocktable> or<apex:repeat>
Example of <Apex:pageblocktable>
<apex:pageBlockTable value="{!invoiclist}" var="invoiclistobj">
<apex:column ><apex:facet name="header">Amount</apex:facet> {!invoiclistobj.amount}</apex:Column>
</apex:pageBlockTable>
</apex:pageBlock>
You can print the value of “sum property using the <apex:outputtext> on VF page
For example
<apex:outputText value="{!sum}"></apex:outputText>
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
I am trying to calculate Total amount (Total_Price_Amount__c).but it's not working-
Take a look at summary formula fields which you could use to create a total field on the invoice object. Then you wouldn't need any apex code....