You need to sign in to do that
Don't have an account?
Problem with IF statement statement
I am developing a Visual force page for endering a pdf file, with the VF page i want to put in IF Condition, but am facing couple of problem. i would like to check the oppty line item value to diplay the total price
My If statement is;
<apex:OutputField value="{!IF((!line.Bill__c="VC"),{!line.TotalPrice},null)}"/>
My table code is
<apex:repeat value="{!Opportunity.OpportunityLineItems}" var="line">
<tr>
<td>{!line.PricebookEntry.Name}</td>
<td>{!line.PricebookEntry.Product2.Status__c}</td>
<td>{!line.Quantity}</td>
<td><apex:OutputField value="{!line.UnitPrice}"/></td>
<td><apex:OutputField value="{!IF((!line.Bill__c="VC"),{!line.TotalPrice},null)}"/></td>
<td><apex:OutputField value="{!IF((!line.Bill__c="FC"),{!line.TotalPrice},null)}"/></td>
</tr>
</apex:repeat>
Please let me know how to fix this issue.
Hi gowthamck,
In an if statement you don{t have to put the "!" before the field, in your case the correct code will be:
Good luck,
Bruno
Hi, thank you for responding, but I tried inserting the syntax you gave it showed me as syntax error
<td><apex:OutputField value="{!IF((line.Bill__c="VC"),{line.TotalPrice},null)}"/></td>
can you please see if this is rite??
Try with this, or
Let me know if this works,
Bruno
Hi Bruno,
its giving me syntax error even after trying some corrections
<td><apex:OutputField value="{!IF((line.Bill__c=VC),{line.TotalPrice},null)}"/></td>
ThankX
CK
<td><apex:OutputField value="{!IF(line.Bill__c='VC'),line.TotalPrice,'')}"/></td>
Syntax error. Extra ','
<td><apex:OutputField value="{!IF(line.Bill__c='VC',line.TotalPrice,'')}"/></td>
Error: Syntax error. Missing ')'
<td><apex:OutputField value="{!IF(line.Bill__c=='VC',line.TotalPrice,'')} "/></td>
It's a comparation so it should be ==
Good luck :)
<apex:OutputField value="{!IF(line.Bill__c=='VC',line.TotalPrice,'')}"/>
Am getting aerror : Missing ')'
I don't know why the reason for this error, but if I put
I see the same error, but with
Its working.
Do you really need a OutputField?
<apex:OutputText value="{!IF(line.Bill__c=='VC',line.TotalPrice,'')}"/>
error: Incorrect parameter for function IF(). Expected Number, received Text
as its a numaric Field , i think outputtext wont fit into this..
if line.Bill__c is a numeric field, you cannot compare it to 'VC', only to a number
Here are the key changes made to your code:
- In your IF statements, I removed the curly braces ({}) around the conditions. You should compare the values directly, like line.Bill__c='VC', without using {}. Look at this bill (https://lescobillonline.net/).
- I used the <apex:OutputText> component to conditionally display the TotalPrice based on the value of line.Bill__c. This is the correct way to conditionally display values in Visualforce.
With these changes, your Visualforce page should correctly display the TotalPrice based on the Bill__c value in your Opportunity Line Items.