You need to sign in to do that
Don't have an account?
Poorna Priya 16
Trigger to Fields Auto populate
I have Custom object named Team__c and Fields are like, Category__c(Picklist), Close_Date__c(Date), Stage__c(Picklist) also have Standard Opportunity object. The Team__c object and Opportunity has look-up relationship with Category__c(Picklist), Close_Date__c(Date), Stage__c(Picklist) fields . In opportunity I have custom field named Type__c(Picklist), whenever the Type__c from Opportunity is equal to 'New Team' (Type__c == 'New Team') the Category__c, Close_Date__c, Stage__c fields should populate in Team__c record while it create. Can anyone help on this? Thanks in advance. I have try with following trigger,
if(trigger.isAfter && trigger.isInsert) { List<Team__c> tt = new List<Team__c>(); Opportunity opp = new Opportunity(); if(opp.Type__c == 'New Team') { for(Opportunity oppty : trigger.new) { Team__c team = new Team__c(); team.Category__c = oppty.Category__c; team.Close_Date__c = oppty.Close_Date__c; team.Stage__c = oppty.Stage__c; tt.add(team); } } }
Can you confirm which is parent and which is child in the relationship and also . I guess Opportunity is parent and Team is child here, If the type is newteam then when new team craeted all the fields should popuate from opportuntiy ?
Are the fields close date, Stage custom fields in opporunity?
Thanks,
Hi Sai,
Yes, Opportunity is parent and Team is child.
If the type is newteam then when new team craeted all the fields should popuate from opportuntiy ? --> Yes
Are the fields close date, Stage custom fields in opporunity? --> Yes
Thanks for confirming the details. Can you try below trigger on team__c object.
Let me know if you face any issues.
If this solution helps, Please mark it as best answer.
Thanks,
Did you get chance to check the above trigger logic. Let me know if you face any issues
Thanks,