Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class OpportunityShipToSelectExtension {
- private final ApexPages.standardController controller;
- private final Opportunity obj;
- public OpportunityShipToSelectExtension(ApexPages.StandardController stdController) {
- this.controller = stdController;
- this.obj = (opportunity)stdController.getRecord();
- }
- public SelectOption[] getShipToOptions() {
- SelectOption[] ShipTo = new SelectOption[]{};
- ShipTo.add(new SelectOption('','--None--'));
- for (ERP_Address__c A : [select Id, Name , Address_Line_1__c, Address_Line_2__c, Address_City__c, Address_State__c FROM ERP_Address__c where ERP_Address__c.Bill_To__r.SFDC_Account__r.ID = : ApexPages.currentPage().getParameters().get('AccountId') ORDER BY Address_Line_1__c ASC NULLS FIRST LIMIT 500]) {
- ShipTo.add(new SelectOption(A.id, A.name + ' (' + A.Address_Line_1__c + ', ' + A.Address_Line_2__c + ', ' + A.Address_City__c + ',' + A.Address_State__c + ')'));
- }
- return ShipTo;
- }
- }
- <apex:page standardController="Opportunity" extensions="OpportunityShipToSelectExtension" showHeader="false" >
- <apex:form id="ShipToForm">
- <apex:pageBlock title="" mode="edit">
- <apex:pageBlockButtons >
- <apex:commandButton action="{!save}" value="Save"/>
- </apex:pageBlockButtons>
- <apex:pageBlockSection title="Select Ship To from Available Addresses" columns="1">
- <apex:pageBlockSectionItem >
- <apex:outputLabel value="{!$ObjectType.opportunity.fields.Ship_To__c.label}" for="pLabel"/>
- <apex:outputPanel styleClass="requiredInput" layout="block">
- <apex:outputPanel styleClass="requiredBlock" layout="block"/>
- <apex:actionRegion >
- <apex:selectList id="ShipToLookupPicklist" value="{!opportunity.Ship_To__c }" size="1" rendered="true">
- <apex:selectOptions value="{!ShipToOptions}"/>
- </apex:selectList>
- </apex:actionRegion>
- </apex:outputPanel>
- </apex:pageBlockSectionItem>
- </apex:pageBlockSection>
- </apex:pageBlock>
- </apex:form>
- </apex:page>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement