Advertisement
Guest User

Untitled

a guest
Jun 29th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. public class OpportunityShipToSelectExtension {
  2. private final ApexPages.standardController controller;
  3. private final Opportunity obj;
  4.  
  5. public OpportunityShipToSelectExtension(ApexPages.StandardController stdController) {
  6. this.controller = stdController;
  7. this.obj = (opportunity)stdController.getRecord();
  8. }
  9.  
  10. public SelectOption[] getShipToOptions() {
  11. SelectOption[] ShipTo = new SelectOption[]{};
  12. ShipTo.add(new SelectOption('','--None--'));
  13. 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]) {
  14. 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 + ')'));
  15. }
  16. return ShipTo;
  17. }
  18. }
  19.  
  20. <apex:page standardController="Opportunity" extensions="OpportunityShipToSelectExtension" showHeader="false" >
  21. <apex:form id="ShipToForm">
  22. <apex:pageBlock title="" mode="edit">
  23. <apex:pageBlockButtons >
  24. <apex:commandButton action="{!save}" value="Save"/>
  25. </apex:pageBlockButtons>
  26. <apex:pageBlockSection title="Select Ship To from Available Addresses" columns="1">
  27. <apex:pageBlockSectionItem >
  28. <apex:outputLabel value="{!$ObjectType.opportunity.fields.Ship_To__c.label}" for="pLabel"/>
  29. <apex:outputPanel styleClass="requiredInput" layout="block">
  30. <apex:outputPanel styleClass="requiredBlock" layout="block"/>
  31. <apex:actionRegion >
  32. <apex:selectList id="ShipToLookupPicklist" value="{!opportunity.Ship_To__c }" size="1" rendered="true">
  33. <apex:selectOptions value="{!ShipToOptions}"/>
  34. </apex:selectList>
  35. </apex:actionRegion>
  36. </apex:outputPanel>
  37. </apex:pageBlockSectionItem>
  38. </apex:pageBlockSection>
  39. </apex:pageBlock>
  40. </apex:form>
  41. </apex:page>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement