0

I'm trying to dynamically set value attribute of commandButton using if condition.

<apex:commandButton value="t" action="{!IF(PototalPayMap[po.id] => po.QA_amount__c,'Paid','Make/View Payments')}" reRender="payment,poHistory,ocHistory">

PototalPayMap[po.id] is a map which i'm getting proper values in debug PototalPayMap--->{a07j0000005pQeVAAU=200.0, a07j0000005pQepAAE=3584485.0}

apex code:

        PototalPayMap = new Map<Id,Decimal>();
        List<AggregateResult> PoPayment = [SELECT SUM(Amount_paid_MUR__c) sumAmount,PO_Item__r.Id FROM PO_Payment__c
                                          where PO_Item__r.Id IN :ids GROUP BY PO_Item__r.id ]; <br/>

        for(AggregateResult agg: PoPayment)
        {
            PototalPayMap.put(agg.Id,(Decimal)agg.get('sumAmount'));
        } 

the Error which i'm getting is: Syntax error. Missing ')' which indicates to the commandButton. I know i'm doing basic mistake pls guide me.

1 Answer 1

1

Instead of using this complex IF commandButton, I strongly recommend you using something in the server side which will make your code much easier to read unless you have a particular reason. Here is the sample code:

Page:

<apex:commandButton value="t" action="{helperMethod}" reRender="payment,poHistory,ocHistory">

Controller:

public pageReference helperMethod() {
    if (PototalPayMap[po.id] == po.QA_amount__c) {
        return Paid();
    }
    else {
        return MakePayments();
    }
}

You must log in to answer this question.

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