You need to sign in to do that
Don't have an account?
MC2014
getting the value from a prefilled inputField.
In my apex, when a contact look up field is selected, it does a query and fill in the in corresponding visual force page inputfield on the form.
When I hit the save button, those field don't get saved, however, the other fields like descpription do. Am I left only to using getter/setters to capture that data in Apex?
Here is the code.
When I hit the save button, those field don't get saved, however, the other fields like descpription do. Am I left only to using getter/setters to capture that data in Apex?
Here is the code.
<apex:page standardcontroller="Case" extensions="Internal"> <apex:form > <apex:pageMessages id="msgs"/> <apex:pageBlock title="My Content"> <apex:actionRegion > <apex:pageBlockSection id="Shipto" title="Ship To Information"> <apex:outputField value="{!case.Ship_To_Account__c}"/> <apex:inputField value="{!case.ShipToContact__c}"> <apex:actionSupport event="onchange" action="{!ShipToPopulated}" rerender="Shipto, msgs"/> </apex:inputField> <apex:inputField value="{!case.Shipping_Address__c}"/> <apex:inputField value="{!case.ShippingCity__c}"/> <apex:inputField value="{!case.ShippingState__c}"/> <apex:inputField value="{!case.ShippingPostalCode__c}"/> <apex:inputField value="{!case.Shipping_Country__c}"/> </apex:pageBlockSection> </apex:actionRegion> <apex:pageBlockSection title="My Content Section2" columns="1"> <apex:inputField value="{!case.Description}" style="width: 90%; min-height: 100px" label="Special Instructions:"/> <apex:outputPanel layout="block" style="align: center"> <apex:commandButton action="{!save}" value="Submit" style="align: center;"/> </apex:outputPanel> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page> public with sharing class Internal { ... public InternalFurfillment(ApexPages.StandardController controller) { this.caseObject = (Case) controller.getRecord(); } .... public PageReference save(){ // a bunch of logic.. but ultimately insert caseRecord; return null; } .... //function where I populate those fields. public void ShipToPopulated() { Contact con = [select c.AccountId, c.Account.Name, c.MailingStreet, c.MailingState, c.MailingPostalCode, c.MailingCity, c.MailingCountry from Contact c where id=:caseObject.ShipToContact__c]; caseObject.Ship_To_Account__c = con.AccountId; caseObject.Shipping_Address__c = con.MailingStreet; caseObject.ShippingCity__c = con.MailingCity; caseObject.ShippingState__c = con.MailingState; caseObject.ShippingPostalCode__c = con.MailingPostalCode; caseObject.Shipping_Country__c = con.MailingCountry; }
Have you debugged your code much? Is the "ShipToPopulated" method getting called? Is the query returning any results? What's the result of caseObject after your logic runs in that method? Also I notice that "line 39" is insert caseRecord and not insert caseObject.. is this just a typo from you pasted your code into this question?
If you find that you're having issues calling ShipToPopulated, you could probably get rid of the action function in your visualforce page and add the query / Shipping logic into your save method if that helps.
All Answers
Have you debugged your code much? Is the "ShipToPopulated" method getting called? Is the query returning any results? What's the result of caseObject after your logic runs in that method? Also I notice that "line 39" is insert caseRecord and not insert caseObject.. is this just a typo from you pasted your code into this question?
If you find that you're having issues calling ShipToPopulated, you could probably get rid of the action function in your visualforce page and add the query / Shipping logic into your save method if that helps.
Something like