+ Start a Discussion
Ashok S 7Ashok S 7 

how can i auto populate the picklist filed in another object

Requirment is:
I have two objects one is A and another one is B .
A is a standard object 
B is a custom object.
In b i created one field name x which is picklist value.
a and b have lookup relation from b to a.
when in b object create new given the x value after save that record that x value automatically populated in a object record.
how can i slove this req . please help me.
Deepthi BDeepthi B
Hello Ashok,

This can be worked on by using Triggers. Please check the below sample code. 
trigger CreateRecObjAAndObjB on ObjectA__c (After insert, After Update) {
            List<ObjectB__c> Blst=new  List<ObjectB__c>();
            for(objectA__c a:Trigger.New) {
                     ObjectB__c b=new ObjectB__c();
                     b.duration__c='3 months';
           insert Blst;
I hope this will help you!
Dorian Sutton 9Dorian Sutton 9
Deepthi B's answer will create a new record of type Object B whenever you create a new Object A.

If I understand your question correctly, you want to update a field in the related Object A record whenever you create a new Object B?

If you are familiar with Apex you could update the code in Deepthi's answer to work over Object B, and update (not insert) the related Object A record.  However, this could also be accomplished using Process Builder.

Create a new Process to be executed whenever an instance of Object B is created or edited and add an Immediate Action of type 'Update Records', then select the option 'Select a record related to Object B'.  

Select the name of the lookup field to Object A then find the name of the field on Object A you need to update.  If you set the type parameter to 'Reference' you can then select the field from Object B you want to be copied into your field in Object A.

Save and Activate the new Process.