How to do a complex IF statement in visualforce

salesforcevisualforce

I'm totally new to this, the task has been thrown at me as important and I've never done anything like this before. I have been given a template containing roughly this:

        <apex:column headervalue="Amount"><c2g:CODAFormatterController number="{!IF([some condition],[something],[something else])}"/></apex:column>

I've replaced the statements with condition/something/something else

is there a way to use a function as you'd do in javascript, so something like

number="getNumber(x);"

or do I have to chain some IF statements together somehow? Is there an IF…ELSE?

I don't know what a CODAFormatterController is as it returned 0 results on google.

Any advice would help, I'm afraid I've been thrown in at the deep end here!

Best Answer

The VForce inlines are functional, they must ultimately return a value, be that a simple value or an invocation point for a piece of server side code. They do not support imperative coding and they are being resolved server-side (long before JS comes into play). in that regard the IF(condition,valuetrue,valuefalse) is an equivalent to IF..THEN..ELSE..ENDIF

You are off course free to chain any number of functions provided there is no type mismatch, meaning your valuetrue could itself be a function, including being an IF function itself.

Usually when people encounter these kind of problems there is always a workaround by using a slightly different approach. It all depends on what you are trying to do here...

Related Topic