function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
jmullins525jmullins525 

Edit Multiple Quote Line Items

I'm trying to build a VF page that will display and allow editing of existing quote line items.  So far I have this:
<apex:page standardController="Quote" showHeader="true" sidebar="false" >
<apex:form >
<apex:pageBlock title="Quote Line Items">
<apex:pageBlockTable value="{!Quote.QuoteLineItems}" var="item">
<apex:column value="{! item.part__c}"/>
<apex:inputField value="{!item.Proposed_Direct_Customer_Price__c}"/>
<apex:commandButton action="{!save}" value="Save!"/>
</apex:pageblocktable>
</apex:pageblock>
</apex:form>
</apex:page>

- The save button and proposed direct customer price do not appear on the page but the part__c read only field does appear for each line item. What am I doing wrong?
Abhi__SFDCAbhi__SFDC
This is becuase in PageBlockTable you need to write column to display the data. Here you are only displaying item.part__c. Kindly try below code  -: 

<apex:column value="{! item.part__c}">
<apex:inputField value="{!item.Proposed_Direct_Customer_Price__c}"/>
<apex:commandButton action="{!save}" value="Save!"/>
</apex:column>


jmullins525jmullins525
When I try to save this: 
<apex:page standardController="Quote" showHeader="true" sidebar="false" >
<apex:form >
<apex:pageBlock title="Quote Line Items">
<apex:pageBlockTable value="{!Quote.QuoteLineItems}" var="item">
<apex:column value="{! item.part__c}">
<apex:inputField value="{!item.Proposed_Direct_Customer_Price__c}"/>
<apex:commandButton action="{!save}" value="Save!"/>
</apex:column>
</apex:pageblocktable>
</apex:pageblock>
</apex:form>
</apex:page>

I get the following error: You may specify either a ''value'' attribute or a body for the column component, but not both. 

Latest version displays static and dynamic fields but the save button is actually saving to the quote, not the line item. So even though it looks like it's saving it's not. 

<apex:page standardController="Quote" showHeader="true" sidebar="false" >
<apex:form >
<apex:pageBlock title="Quote Line Items">
<apex:pageBlocktable value="{!Quote.QuoteLineItems}" var="item">

<apex:column headerValue="Part Number">
<apex:outputField value="{!item.Part__c}" />
</apex:column>

<apex:column headerValue="unit price">
<apex:inputtext value="{!item.UnitPrice}" />
</apex:column>
<apex:column headerValue="quantity">
<apex:inputtext value="{!item.Quantity}" />
</apex:column>

</apex:pageblocktable>
<apex:pageblockbuttons >
<apex:commandButton action="{!save}" value="Save!"/>
</apex:pageblockbuttons>
</apex:pageblock>
</apex:form>
</apex:page>

I wrote a custom controller but I think I need to write the save functionality to the quote line item in the custom controller and I'm not sure how to do that... am I going down the right path?

public class MyQuoteLIController {

    public PageReference save() {
        return null;
    }

public Quote getQuote() {
return [SELECT id, name,
(SELECT Id, Part__c, Quantity, UnitPrice, QuoteId
FROM QuoteLineItems)
FROM Quote WHERE id =
:System.currentPageReference().getParameters().get('id')];
}
}

Thank you!!


Abhi__SFDCAbhi__SFDC
Yes you are right you you need to write a customer controller for that. If you need Quote Data via standard controller ,
you can use extension controller to get QuoteLineItems and can write the logic to save that in the controller .Let me know if you get any issues.