1

I am doing simple calculation to get the value on VFPage but it doesn't come up with any value.

below is the example

<apex:column headervalue="SLMTotal"
<apex:outputtext value="{!(slm.field1+slm.field2+slm.field3)*(slm.field4)}"/>
</apex:column>

I have checked slm.field4 does have value so it is not X 0 error.

What could it be? Does any one please suggest?

3
  • what is slm, can you paste the controller
    – Rao
    Sep 17, 2015 at 17:00
  • slm stands fro opportunity standard object
    – Ricky
    Sep 17, 2015 at 17:13
  • do you see just blank, it will be helpful If you can paste how you are populating the slm. I see no issue as such with the way you are calculating the value of the outputtext
    – Rao
    Sep 17, 2015 at 17:25

1 Answer 1

2

If any of the fields is blank, then the entire expression will be evaluated as a blank. i.e. blanks will not be treated as zeros.

The following expression should work.

<apex:column headervalue="SLMTotal"
    <apex:outputtext value="{!(NULLVALUE(slm.field1,0)+NULLVALUE(slm.field2,0)+NULLVALUE(slm.field3,0))*(NULLVALUE(slm.field4,0))}"/>
</apex:column>

The function NULLVALUE() replaces nulls with an alternate expression, in this case with zero.

1
  • Oh is it really? Let me try this.
    – Ricky
    Sep 17, 2015 at 18:21

You must log in to answer this question.

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