You need to sign in to do that
Don't have an account?
Saving and Associating Coded Input Field Data to Opportunity Record
Hi SF Community,
I'm an Admin, not a Developer, but I have dabbled in some code to help meet some of my needs.
I recently had some help from a developer on this forum, in creating a visualforce page that I can input as a section on the Opporunity page layout.
Here's what it looks like:
When I input values in these fields, they don't save to the related opportunity. Does anyone know how I can accomplish this?
Here's my existing code...
Visualforce:
01<apex:page standardController="Opportunity" extensions="GroupInsertController">
02 <apex:form >
03 <apex:pageBlock >
04 <apex:pageblockSection >
05 <apex:pageBlockTable value="{!OpportunityAddList}" var="std">
06 <apex:column headerValue="SOW Item">
07 <apex:inputField value="{!std.SOW_Item__c}"/>
08 </apex:column>
09 <apex:column headerValue="SOW Hours">
10 <apex:inputField value="{!std.SOW_Hours__c}"/>
11 </apex:column>
12 <apex:column headerValue="SOW Item Cost">
13 <apex:inputField value="{!std.SOW_Item_Cost__c}"/>
14 </apex:column>
15 </apex:pageBlockTable>
16 <br/><apex:commandLink value="Add Row" action="{!addRow}"/>
17 <br/><apex:commandLink value="Remove Row" action="{!delRow}"/>
18 </apex:pageblockSection>
19 <apex:pageblockButtons >
20 <apex:commandButton value="Save" action="{!groupInsert}" />
21 </apex:pageblockButtons>
22 </apex:pageBlock>
23 </apex:form>
24</apex:page>
Controller:
view sourceprint?
01public class GroupInsertController{
02
03 public List<Opportunity> OpportunityAddList {get;set;}
04 public List<Opportunity> opp {get; set;}
05
06 public GroupInsertController(ApexPages.StandardController stdController)
07 {
08 Opportunity s = new Opportunity();
09 OpportunityAddList = new List<Opportunity>();
10 opp = new List<Opportunity>();
11 OpportunityAddList.add(s);
12 }
13
14 public void addRow()
15 {
16 Opportunity s1 = new Opportunity();
17 OpportunityAddList.add(s1);
18 }
19
20 public void delRow()
21 {
22 Integer i=OpportunityAddList.size();
23 OpportunityAddList.remove(i-1);
24 }
25
26 public PageReference groupInsert(){
27 try{
28 for(Opportunity s2 : OpportunityAddList){
29 opp.add(s2);
30 }
31 insert opp;
32 }
33 catch (Exception e) {
34 ApexPages.addMessages (e);
35 }
36 PageReference pr = new PageReference(System.currentPageReference().getURL());
37 pr.setRedirect(true);
38 return pr;
39 }
40}
Thanks!
Nick