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
dannodanno 

save button with standard controller fails without error

I have a custom page for multiline editing of opportunity product line items

 

The code looks a bit like this;

 

apex:page standardController="Opportunity">        
<apex:pageMessages />
<apex:includeScript value="{!URLFOR($Resource.JQuery, '')}"  />
<apex:stylesheet value="{!URLFOR($Resource.customStyle, '')}"  />
<script>
  // some nifty scripts
</script>
<style>
    .accountLink { color: blue; cursor: pointer; cursor: hand; }
</style>
 
  <apex:form id="EditAllProductsLine_Form">
 
    <apex:pageBlock title="Edit Products for {!Opportunity.Name}" mode="edit">
        <apex:pageBlockButtons >
            <apex:commandButton onclick="message()" action="{!save}" value="Save and move on.."/>
            <apex:commandButton action="{!cancel}" value="Cancel"/>
        </apex:pageBlockButtons>

        <apex:dataTable value="{!Opportunity.OpportunityLineItems}" var="lines" id="theTable" rowClasses="quoteRow"
                        styleClass="tableClass" cellpadding="3" cellspacing="3">      
            <apex:column headerValue=" Quantity ">
                <apex:inputField value="{!lines.Quantity}" style="width: 30px;" styleClass="qnty"/>
            </apex:column>
            <apex:column headerValue=" Product " style="align: center;">
                <textarea class="prdName" rows="2" style="width: 350px;">{!lines.Product_Name__c}</textarea>
                <apex:inputField value="{!lines.description}" style="visibility:hidden;" styleClass="desc"/>
            </apex:column>
            <apex:column headerValue=" Cost Price " style="width: 70px;">
                <apex:inputField value="{!lines.cost__c}" style="width: 70px;" styleClass="cost"/>
            </apex:column>  
            <apex:column headerValue=" Margin " style="width: 30px;">
                <apex:inputField value="{!lines.Margin__c}" style="width: 35px;" styleClass="marg"/>
            </apex:column>
            <apex:column headerValue=" Sell Price ">
                <apex:inputField value="{!lines.UnitPrice}" style="width: 90px;" styleClass="slPrc rwNum"/>
            </apex:column>
            <apex:column headerValue=" Row Total ">
                <apex:outputText value="{!lines.Subtotal}" style="width: 90px;" styleClass="rowSub rwNum"/>
            </apex:column>
        </apex:dataTable>
        
        <div>
            <p>Total Cost: <span id="totCost"></span></p>
            <p>Total Sale: <span id="totSale"></span></p>
            <p>Quote Margin: <span id="totMrgn"></span></p>
            <p>Gross Profit: <span id="totPrft"></span></p>
        </div>


    </apex:pageBlock>
  </apex:form>
</apex:page>

 

When i hit the save button the browser goes back to the opportunity as expected but the field values are not being saved.

 

I am very new to this platform but from what i have seen from googling around this should be working!

 

Can someone please point me in the right direction.

 

Many thanks :) 

souvik9086souvik9086

Is there any specific reason for the onclick in button? You can check by removing that once.

 

 <apex:commandButton onclick="message()" action="{!save}" value="Save and move on.."/>

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks

dannodanno

Hi Souvik,

 

Thanks for your reply. I had tried it without the onclick event and have just tried it again, with no difference, the action still fails to update the database.

 

I take it from your reply that this should in fact be working as it is.. is there a way to catch any error messages that may be generated by the save action? It would help with debugging if i could view the output.

 

Just to clarify, i am using the developer version of salesforce 13 and the visualforce page is at:

 

wip.ap1.visual.force.com/apex/oppmods?oppId=0069000000CKSU7&retURL=%2F0069000000CKSU7&sfdc.override=1&id=0069000000CKSU7 

 

and the save action brings me back to:

 

ap1.salesforce.com/0069000000CKSU7

 

 

I am really stuck at this point! Any help would be appreciated.  :) 

dannodanno

I have made some progress, i found that if i use the OpportunityLineItem standard controller instead of Opportunity standard controller, and then use the id of a line item instead of an opportunity in the URL the save function works! :)

 

Of course the downside is that i am no longer editing all line items... just the one in the id=string. :(

 

Am i on the right track here? Is the problem with the standard controller i have chosen? If so how do i fix this??

Puja_mfsiPuja_mfsi

Hi,

You have used standard controller "opportunity" and use standard save functionality , So the save functionality is refer to the opportunity save functionality not for OpportunityLineItem.

But now u use the standardController "opportunityLineItem" so the code working fine because in this case the save functionality is refer to the opportunitylineItem.But due to this you can edit only one line item at one time.

 

Please explain your reauirement little more either u want to edit onle line item at one time or more.

 

dannodanno

Hi Puja,

 

The page is loaded from the 'edit all' button on the oportunities product list. I want to edit all records at once.

 

Should this work?