0
(!GWB_Utility.isNull(cust.FinancialIndicator)?cust.FinancialIndicator == 'Y'? 'Yes':cust.FinancialIndicator == 'N'? 'No':null);

Idea - the value will be either Y/N/Null - If it's Y show Yes , N show No and null if null

Where am I going wrong?

1 Answer 1

6

Don't use multiple ternary operators in one line. It's way too confusing to be worth it. Here's what you have:

/*condition1*/ !GWB_Utility.isNull(cust.FinancialIndicator) ?
    /*truthy_value1*/ /*condition2*/cust.FinancialIndicator == 'Y' ?
        /*truthy_value2*/ 'Yes' :
        /*falsy_value2*/ /*condition3*/ cust.FinancialIndicator == 'N' ?
            /*truthy_value3*/ 'No' :
            /*falsy_value3*/ null;

You are missing /*falsy_value1*/.

I advise using a more verbose if/else syntax here. It will be much easier to work with:

String output;
if (input == 'Y') output = 'Yes';
if (input == 'N') output = 'No';

You must log in to answer this question.

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