You need to sign in to do that
Don't have an account?
How do you select a pick-list value in a trigger
I have a tigger that creates a new record for 4 diffrent fields on Goal Object. It creates 4 new records at one time on a object called Quarterly Goal. This seems smiple...I would like to select a value in a picklist called Fiscal Quarter: Picklist Values Q1,Q2,Q3,Q4.
Expamlpe:
Object (Goal) > Field (Goal Q1) = Object (Quarterly Goal) > Field (Quarterly Goal = Q1)
Her is my Tigger that I've had help on...a lot of help! Thank You!
Expamlpe:
Object (Goal) > Field (Goal Q1) = Object (Quarterly Goal) > Field (Quarterly Goal = Q1)
Her is my Tigger that I've had help on...a lot of help! Thank You!
trigger CreateGoalSplits on Goal__c (after insert, after update) { if( trigger.isInsert ) { List<Goal_Split__c> goalSplits = new List<Goal_Split__c>(); for( Goal__c goal : trigger.new ) { if( goal.GoalQ1__c != null ) { Goal_Split__c goalSplit = new Goal_Split__c( GoalAmount__c = goal.GoalQ1__c, ClientOwner__c = goal.ClientOwner__c, AdditionalOwner__c = goal.AdditionalOwner__c, AgencyOwner__c = goal.AgencyOwner__c, GoalNumber__c = goal.Id ); goalSplits.add( goalSplit ); } if( goal.GoalQ2__c != null ) { Goal_Split__c goalSplit = new Goal_Split__c( GoalAmount__c = goal.GoalQ2__c, ClientOwner__c = goal.ClientOwner__c, AdditionalOwner__c = goal.AdditionalOwner__c, AgencyOwner__c = goal.AgencyOwner__c, GoalNumber__c = goal.Id ); goalSplits.add( goalSplit ); } if( goal.GoalQ3__c != null ) { Goal_Split__c goalSplit = new Goal_Split__c( GoalAmount__c = goal.GoalQ3__c, ClientOwner__c = goal.ClientOwner__c, AdditionalOwner__c = goal.AdditionalOwner__c, AgencyOwner__c = goal.AgencyOwner__c, GoalNumber__c = goal.Id ); goalSplits.add( goalSplit ); } if( goal.GoalQ4__c != null ) { Goal_Split__c goalSplit = new Goal_Split__c( GoalAmount__c = goal.GoalQ4__c, ClientOwner__c = goal.ClientOwner__c, AdditionalOwner__c = goal.AdditionalOwner__c, AgencyOwner__c = goal.AgencyOwner__c, GoalNumber__c = goal.Id ); goalSplits.add( goalSplit ); } } if( goalSplits.size() > 0 ) insert goalSplits; } else if( trigger.isUpdate ) { List<Goal_Split__c> goalSplits = new List<Goal_Split__c>(); List<Goal__c> goals = [ Select Id, AgencyOwner__c, AdditionalOwner__c, ClientOwner__c, (Select AgencyOwner__c, AdditionalOwner__c, ClientOwner__c, Id from Goal_Resources__r) from Goal__c where Id IN: trigger.new ]; for( Goal__c g : goals ) { if( trigger.oldMap.get( g.Id ).AgencyOwner__c != g.AgencyOwner__c || trigger.oldMap.get( g.Id ).AdditionalOwner__c != g.AdditionalOwner__c || trigger.oldMap.get( g.Id ).ClientOwner__c != g.ClientOwner__c ) { for( Goal_Split__c gs : g.Goal_Resources__r ) { gs.AdditionalOwner__c = g.AdditionalOwner__c; gs.AgencyOwner__c = g.AgencyOwner__c; gs.ClientOwner__c = g.ClientOwner__c; goalSplits.add( gs ); } } } if( goalSplits.size() > 0 ) update goalSplits; } }
If you want to assign a value to a picklist field, simply do the following: For example:
Please let me know if this helps.
If yes, please mark the Question as Solved.
Thanks and Regards,
Anirudh Singh
All Answers
If you want to assign a value to a picklist field, simply do the following: For example:
Please let me know if this helps.
If yes, please mark the Question as Solved.
Thanks and Regards,
Anirudh Singh
Prentiss Jones 3,
After selecting values in pick list how can you remove value from pick list after record saved..............