I would like to create a VF page ("AllUnitIdssaved") that will accept users inputs. This VF page is on the "Shipment_Details__c", which has a lookup to "QuoteLineItem". When the user clicks a custom button ("Create Unit Id") on the Shipment_Details related list, it should bring up the VF page.
A couple things I need help on:
I'm getting an error when I click the "Create Unit Id" button. Below is my setup for my custom button.
Behavior: Display in existing window with sidebar
Button or Link URL: window.location = '/apex/AllUnitIdssaved';How do I link the Shipment_Details records that are being created on the Visualforce page to the Quote Line Item records? Here's my markup:
<apex:page Controller="AddmultipleUnitIdsController"> <apex:form > <apex:pageBlock > <apex:pageBlockTable value="{!listUnitId}" var="unit"> <apex:column headerValue="Create Unit Id"> <apex:inputField value="{!unit.Name}"/> </apex:column> </apex:pageBlockTable> <apex:pageBlockButtons > <apex:commandButton value="Create Unit Ids" action="{!addUnitId}"/> <apex:commandButton value="Save Unit Ids" action="{!saveUnitId}"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>
Controller:
public class AddmultipleUnitIdsController { Shipment_Detail__c unitid = new Shipment_Detail__c(); public list<Shipment_Detail__c> listUnitId{ get; set; } public AddmultipleUnitIdsController() { listUnitId=new list<Shipment_Detail__c>(); listUnitId.add(unitid); } Public void addUnitId() { Shipment_Detail__c unit = new Shipment_Detail__c(); listUnitId.add(unit); } public PageReference saveUnitId() { for(Integer i=0; i<listUnitId.size(); i++) { insert listUnitId; } return Page.AllUnitIdssaved; } }