You need to sign in to do that
Don't have an account?
Adriana Reyes 7
Save Visualforce fields selection to another object?
So I have an object called Purchase Requisition that has a button that leads the user to a pop up visualforce page where they select a Warehouse from a picklist which is another custom object. The picklist is generated by all of the records in the Warehouse object. I had to do this because users don't have access to Warehouse due to the cost of licensing. I want whatever their selection is on that window and then hit save, to then save the warehouse name as a text field on the purchase requisition records that they started with. I'm not really sure how to go about that. Here is the VF page and controller that I have built so far. Any help is appreciated!
public class selectWarehouse { private final Purchase_Requisition__c pr; public selectWarehouse(ApexPages.StandardController stdController) { this.pr = (Purchase_Requisition__c)stdController.getRecord(); } public string selectedWarehouse{get;set;} public list<SelectOption> getWarehousenames() { List<SelectOption> options = new List<SelectOption>(); for (Warehouse__c w : [select name from Warehouse__c order by name desc limit 100]) { options.add(new SelectOption(w.name, w.name)); } return options; } }
<apex:page lightningStylesheets="true" standardController="Purchase_Requisition__c" extensions="selectWarehouse" showHeader="false"> <apex:form > <apex:pageBlock title="Select A Warehouse"> <apex:outputLabel value="Warehouse "/> <apex:selectList size="1"> <apex:selectOptions value="{!Warehousenames}"> </apex:selectOptions> </apex:selectList> <apex:pageBlockButtons > <apex:commandButton action="{!save}" value="Save"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page
Apex Class
String selectedWarehouseValue{get;set;}
Visualforce Page
<apex:selectList size="1" value="{!selectedWarehouseValue}">
<apex:selectOptions value="{!Warehousenames}">
</apex:selectOptions>
</apex:selectList>
Apex Class
public void save(){
System.debug('Selected Warehouse Value'+selectedWarehouseValue);
}