You need to sign in to do that
Don't have an account?
Ahmad Amiri
Auto fill fields that base on a picklist.
Hi
I have three fields that base on a picklist ‘postcode’ in my custom object ‘Address’.
I want write a code to auto fill fields (Country, State,... ) base on the “Post code”. So if a user change value on pick list it should directly populate value to others text fields.
I know that there are different ways to do it but there are not proper for this example.
• Write apex and use trigger, it is work but after saving the record.
• Workflow formula has limited length and in this case we have 290 “Post code” so formula becomes an out of size
• The last one is use VisualForce page with apex class. This one is work if I want create the page from scratch or override the page.
My question is how can I create a customize “Address” to modify the page? Like add “event="onchange"” to pick list or send value to extension controller.
Or if there is another way to solve this problem.
Thanks in Advance.
I have three fields that base on a picklist ‘postcode’ in my custom object ‘Address’.
I want write a code to auto fill fields (Country, State,... ) base on the “Post code”. So if a user change value on pick list it should directly populate value to others text fields.
I know that there are different ways to do it but there are not proper for this example.
• Write apex and use trigger, it is work but after saving the record.
• Workflow formula has limited length and in this case we have 290 “Post code” so formula becomes an out of size
• The last one is use VisualForce page with apex class. This one is work if I want create the page from scratch or override the page.
My question is how can I create a customize “Address” to modify the page? Like add “event="onchange"” to pick list or send value to extension controller.
Or if there is another way to solve this problem.
Thanks in Advance.
Please mark my answer as a solution to your question if it solves your problem.
All Answers
All you need to do is to write a ApexTrigger on Before/After insert and Update whichever suites you better and then assign the value for Country and State field according to Postal code.
Please mark my answer as a solution to your question if it solves your problem.
Thanks for your answer.
You solution is work but after I click the save button I want populate value in text fields directly when I change the value in picklist.
I know that but I couldn't find a way to add code to existing page or override the picklist. I know how to write visual force page from scratch.
Please mark my answer as a solution to your question if it solves your problem.