You need to sign in to do that
Don't have an account?
SuAk
Need to update a value based on the picklist value before saving the record
Hi,
I have a requirement where on the EDIT Page(the edit page when we click on New on the object), When User select a value on the picklist to "Bill To" the field in the Location Name should be "Bill To Address". This needs to be pre populated before saving the record.
As per the picture above, the location name should be updated in this screen to "Bill to Address" as soon as the user select the Type "Bill To" and user should be allowed to overwrite the Location Name "Bill to Address" to something and save the record.
Let me know if there are any solution to this.
Thanks,
Sujatha.M
I have a requirement where on the EDIT Page(the edit page when we click on New on the object), When User select a value on the picklist to "Bill To" the field in the Location Name should be "Bill To Address". This needs to be pre populated before saving the record.
As per the picture above, the location name should be updated in this screen to "Bill to Address" as soon as the user select the Type "Bill To" and user should be allowed to overwrite the Location Name "Bill to Address" to something and save the record.
Let me know if there are any solution to this.
Thanks,
Sujatha.M
Fields cannot be dynamically pre-pulated via standard functionality. Using csutom code, this can be achieved in 2 ways.
1. Override the New Button and create a custom visualforce edit page. You can have javascript in that page to dynallically populated the field based on other field values.Example (http://www.oyecode.com/2013/04/how-to-prepopulate-text-box-field-on.html)
2.Not 100 % percent suer abt this but you could create a homepage component with a snippet of Jquery code to populate values selected in other fields.
As per your requirement i have written a trigger hope it solves your problem.
trigger Handler class
Regards
Suraj
@Suraj - Thank you for your response. Trigger works only when I click on the Save button. I need this before clicking on save.
Thats a sample code for overriding New/Edit buttons. You have to build logic using Javascript in to the page to dynamically prepoulate the field. Somethin like below.
<apex:page standardController="Your_Object__c" extensions="Customcontroller">
<script>
function location()
{
var Type = document.getElementById('{!$Component.form1.pblock.locationobject.Type__c}').value;
var location =document.getElementById('{!$Component.form1.pblock.locationobject.Type__c}');
if (Type = 'Bill To')
{
location.value= "Bill To Address";
}
window.onload=function()
{
location();
}
</script>
<apex:form id="form1">
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlockButtons>
<apex:pageblocksection id="locationobject" columns="2" title="LOC">
<!--add other fields-->
<apex:inputField id="Type__c" onchange="location();" value="{!Your_Object__c.Type__c}"/>
<apex:inputField id="Location_Name__c" value="{!Your_Object__c.Location_Name__c}"/>
</apex:pageblocksection>
</apex:pageBlock>
</apex:form>
</apex:page>
Please excuse any typos.