0

I have a table that shows the QuoteLineItem's information and I have the UnitPrice in a textfield so it can be changed, using an action support and param to call an apex code method that updates it. Only problem is it doesn't work at all.

<apex:column title="Unit Price">
           <apex:inputField value="{!item.UnitPrice}" label="UnitPriceID={!item.id}" >
                 <apex:actionsupport event="onchange" rerender="qlitems" status="status" >
                     <apex:param name="qliID" assignTo="{!qliID}" value="{!item.id}" />
                     <apex:param name="qliUnitPrice" assignTo="{!qliUnitPrice}" value="UnitPriceID{!item.Id}" />
                 </apex:actionsupport>
           </apex:inputField>
 </apex:column>

Here is the apex code for it as well:

public pageReference udpateQuoteLineItems(){
    //Update QuoteLineItem as needed
    list<QuoteLineItem> myQliList = new list<QuoteLineItem>();
    myQliList = [Select id, UnitPrice, Quantity, TotalPrice from QuoteLineItem where id=:qliID];
    if(myQliList.isEmpty() == false){
        Decimal qUP = Decimal.valueof(qliUnitPrice);
        Integer qQty = Integer.valueof(qliQuantity);
        myQliList[0].Quantity = qQty;
        myQliList[0].UnitPrice = qUP;
        System.assertEquals(myQliList[0].TotalPrice, (myQliList[0].Quantity * myQliList[0].UnitPrice));
        update myQliList[0];
    }
    return null;
}
0

One problem is that you are not invoking the Apex method:

<apex:actionsupport event="onchange" rerender="qlitems" status="status" >

To do so add:

<apex:actionsupport action="{!udpateQuoteLineItems}" event= ... >

PS

Not sure what you are aiming to do in the method but if its only to update the database this is all that's needed:

public PageReference udpateQuoteLineItems() {
    Decimal u = Decimal.valueof(qliUnitPrice);
    Integer q = Integer.valueof(qliQuantity);
    update new QuoteLineItem(
            Id = qliID,
            Quantity = q,
            UnitPrice = u,
            TotalPrice = (q * u).setScale(2)
            );
    return null;
}

System.assertEquals is mostly used in tests or to assert conditions that should never happen as it throws an exception when the values are not equal (and the values won't be equal if the user is editing the quantity or unit price.

8
  • I get an error that states Standard Object Quote does not have that method
    – Mike Stomp
    Jul 2 '15 at 17:34
  • @MikeStomp Have you referenced the controller class that contains your udpateQuoteLineItems method in the apex:page tag? See e.g. Building a Controller Extension.
    – Keith C
    Jul 2 '15 at 17:36
  • I can't reference it like that I get the same error
    – Mike Stomp
    Jul 2 '15 at 18:17
  • I can reference the greeting but It still doesnt understand the updateQuoteLineItems method
    – Mike Stomp
    Jul 2 '15 at 18:33
  • I'm an idiot. I mispelled update in my method.
    – Mike Stomp
    Jul 2 '15 at 18:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.