I am new to creating triggers and would love some assistance in creating a trigger that can mirror a picklist values.
I have two identical picklists called "Test_Status__c" on both the Account object and on the Contact object that contain the following values:
Prospect Member Probation Emeritus Terminated
I am looking to create a trigger where if say "Prospect" is selected as a value on the Account, that its Contacts' picklist fields would display "Prospect" as well. I am looking for this information to roll down from the Account and not up from the Contact.
I would create a formula field on the Contact object that would draw in the Account's picklist value, but I need the field on the Contact page to stay editable.
I have tried to pick up some hints online of how to create this trigger and have come up with the following code thus far:
trigger FieldUpdate on Contact (before insert, before update){
Map<String, String> myPickListMap = new Map<String, String> {'Prospect'=>'Prospect', 'Member'=> 'Member','Probation'=>'Probation','Emeritus'=>'Emeritus','Terminated'=>'Terminated'};
for (Account a : Trigger.new) || for (Contact c : Trigger.new) {
if(a.Test_Status__c != null) {
c.Test_Status__c = myPickListMap.get(a.Test_Status__c);
}
}
}