function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
imishraimishra 

Dynamically populating values

In the Account Object i have custom picklist for District and a number field called Postal Code.
I want to dynamically populate the postal code when the user selects the district before the record is saved.

Please let me know how can i do it.

Thanks in advance.
Best Answer chosen by imishra
Gonzalo AbrunaGonzalo Abruna
You have some options:
  1. Usage of dependent picklists: basically in this case Postal Code should be a Picklist (not a number), depending on District value, you can find more information about dependent pickslists here: https://help.salesforce.com/HTViewHelpDoc?id=fields_defining_field_dependencies.htm&language=en_US (https://help.salesforce.com/HTViewHelpDoc?id=fields_defining_field_dependencies.htm&language=en_US) The drawback of this approach is that either you change Field Type for Postal Code, or you create a new field to replace its functionality.
  2. Usage of VF development: if you are already in a VF page (you didn't specify it, that's why I am not sure), you can use an actionSupport which will update the value of Postal Code in a method in the server, and afterwards, rerender the part of code where Postal Code is, exactly as it is shown in this topic: http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_actionSupport.htm
Regards,

Gonzalo.

All Answers

Gonzalo AbrunaGonzalo Abruna
You have some options:
  1. Usage of dependent picklists: basically in this case Postal Code should be a Picklist (not a number), depending on District value, you can find more information about dependent pickslists here: https://help.salesforce.com/HTViewHelpDoc?id=fields_defining_field_dependencies.htm&language=en_US (https://help.salesforce.com/HTViewHelpDoc?id=fields_defining_field_dependencies.htm&language=en_US) The drawback of this approach is that either you change Field Type for Postal Code, or you create a new field to replace its functionality.
  2. Usage of VF development: if you are already in a VF page (you didn't specify it, that's why I am not sure), you can use an actionSupport which will update the value of Postal Code in a method in the server, and afterwards, rerender the part of code where Postal Code is, exactly as it is shown in this topic: http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_actionSupport.htm
Regards,

Gonzalo.
This was selected as the best answer
imishraimishra
Thanks Gonzalo.
I am already in visualforce page. I'll try the second option.
Gonzalo AbrunaGonzalo Abruna
Cool, good luck with that one! :)