You need to sign in to do that
Don't have an account?
tobias.brand
save button for opportunitylineitems
Hello Forum,
I have searched this Forum for an answer to my question, but I can´t find anything suiting my issue. As I am new to visualforce I am a rooky with apex ... maybe my issue is just some small code - I don´t know. Here is what it is about:
I have written a visual force page:
<apex:page standardController="Opportunity" sidebar="false">
<apex:form >
<p>You are viewing data from Opportunity "{!opportunity.name}".</p>
<p>The related account is {!opportunity.account.name}.</p>
<br/>
<p>Enter the quantity for each product you want to invoice. Leave field blank to exclude it from invoicing.</p>
<p>Click "save" to create your invoice or click "back" to do nothing.</p>
<apex:pageBlock mode="inlineEdit">
<apex:pageMessages />
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!quicksave}"
oncomplete="window.parent.location.href=('/apex/invoicing2?Id={!Opportunity.Id}')"/>
<apex:commandButton value="Back" action="{!cancel}"/>
</apex:pageBlockButtons>
<apex:pageblockTable value="{!Opportunity.OpportunityLineItems}" width="100%" var="ml">
<apex:column value="{!ml.quantity}" />
<apex:column value="{!ml.UnitPrice}"/>
<apex:column value="{!ml.Discount}"/>
<apex:column value="{!ml.TotalPrice}"/>
<apex:column value="{!ml.invoice_2_quantity__c}"/>
<apex:column value="{!ml.invoice_2_amount__c}"/>
<apex:column value="{!ml.listprice}"/>
<apex:column >
<apex:inputfield value="{!ml.flow_inv_QuantityToInvoice__c}"/>
</apex:column>
</apex:pageblockTable>
</apex:pageblock>
</apex:form>
</apex:page>
I have a save button on this page, but it doesn´t save the changes (I understand it is because of standard controller Opportunity). But how do I get a button to save my changes to OpportunityLineItem?
Any help is welcome.
tobias
I have searched this Forum for an answer to my question, but I can´t find anything suiting my issue. As I am new to visualforce I am a rooky with apex ... maybe my issue is just some small code - I don´t know. Here is what it is about:
I have written a visual force page:
<apex:page standardController="Opportunity" sidebar="false">
<apex:form >
<p>You are viewing data from Opportunity "{!opportunity.name}".</p>
<p>The related account is {!opportunity.account.name}.</p>
<br/>
<p>Enter the quantity for each product you want to invoice. Leave field blank to exclude it from invoicing.</p>
<p>Click "save" to create your invoice or click "back" to do nothing.</p>
<apex:pageBlock mode="inlineEdit">
<apex:pageMessages />
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!quicksave}"
oncomplete="window.parent.location.href=('/apex/invoicing2?Id={!Opportunity.Id}')"/>
<apex:commandButton value="Back" action="{!cancel}"/>
</apex:pageBlockButtons>
<apex:pageblockTable value="{!Opportunity.OpportunityLineItems}" width="100%" var="ml">
<apex:column value="{!ml.quantity}" />
<apex:column value="{!ml.UnitPrice}"/>
<apex:column value="{!ml.Discount}"/>
<apex:column value="{!ml.TotalPrice}"/>
<apex:column value="{!ml.invoice_2_quantity__c}"/>
<apex:column value="{!ml.invoice_2_amount__c}"/>
<apex:column value="{!ml.listprice}"/>
<apex:column >
<apex:inputfield value="{!ml.flow_inv_QuantityToInvoice__c}"/>
</apex:column>
</apex:pageblockTable>
</apex:pageblock>
</apex:form>
</apex:page>
I have a save button on this page, but it doesn´t save the changes (I understand it is because of standard controller Opportunity). But how do I get a button to save my changes to OpportunityLineItem?
Any help is welcome.
tobias
You would need to create a Controller Extension: http://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_extension.htm
And then create a SaveLineItems Method in your controller extension class to save the line-items.
public class saverecord
{
public Opportunity opp{get;set;}
public saverecord(ApexPages.StandardController stdController)
{
opp = [SELECT Id (SELECT Quantity,
PricebookEntry.Name, Description, UnitPrice, flow_inv_QuantityToInvoice__c FROM
OpportunityLineItems ) FROM Opportunity where id
=:ApexPages.currentPage().getParameters().get('id')];
}
public PageReference save()
{
update opp; update opp.opportunitylineitems;
return null;
}
}
Visual force site is like in my first post; I just put in "extensions="saverecord" to call the custom controller. But this is not saving anything. Is there any helping hand outside?
Best, tobias