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
jroyaltyjroyalty 

Saving OpportunityLineItems isn't working

Hello,

 

I'm trying to set up a custom page so that I can add some references for the Opportunity List Item page.  Unfortunately, when I try to Save my edited values nothing changes in the records.  I would like to do this only using a standard controller.  Here's the code I'm using just for this test:

 

 

<apex:page standardController="Opportunity" tabstyle="opportunity">
 <apex:form >
   <apex:pageBlock >
    <apex:pageBlockTable value="{!Opportunity.opportunitylineitems}" var="a">
     <apex:column headerValue="Price">
      <apex:inputField value="{!a.quantity}"/>
     </apex:column>
    </apex:pageBlockTable>
    <apex:commandButton value="Save" action="{!quicksave}"/>
  </apex:pageBlock>
 </apex:form>
</apex:page>

 

Is there something I can do to set it up to properly be able to save the modified line item values?

 

Any help would be appreciated.


Thanks!

Best Answer chosen by Admin (Salesforce Developers) 
SteveBowerSteveBower

Oh, I'm sorry, I responded too fast when I saw the "quicksave" thing.   All the actions you get from the standardController are actions on the Opportunity Record itself.  However, you're making changes to the LineItems, and those are different records.  The "save" doesn't propogate down to the related list of objects.

 

So,  I think you need a simple extension which, upon save, would issue an update for the List of OpportunityLineItems that are referred to in the Opportunity.

 

Best, Steve

All Answers

SteveBowerSteveBower

What is: "quicksave"?

 

try 

 

action="{!Save}"

 

instead.

 

Best, Steve.

 

p.s. Header = "Price", value = "Quantity"... misleading to say the least!  :-) (Although I realize it's just a test...)

jroyaltyjroyalty

Quicksave does a save without leaving the page, it was an artifact of a test I was doing to try to resolve the problem.


Save does not work either.

SteveBowerSteveBower

Oh, I'm sorry, I responded too fast when I saw the "quicksave" thing.   All the actions you get from the standardController are actions on the Opportunity Record itself.  However, you're making changes to the LineItems, and those are different records.  The "save" doesn't propogate down to the related list of objects.

 

So,  I think you need a simple extension which, upon save, would issue an update for the List of OpportunityLineItems that are referred to in the Opportunity.

 

Best, Steve

This was selected as the best answer
jroyaltyjroyalty

Thank you, I'll look into doing that.

jbardetjbardet

did you ever do this? would be nice to share the actual solution for newbs like me.

 

Thanks :)

Kermoony developerKermoony developer

Howdy,

We know this is an old thread, but over the weekend we had to deliver something similar to this and were much appreciative of the knowledge shared by this community.  We've shared a blog post on how we solved the issue and would welcome your comments.