You need to sign in to do that
Don't have an account?

Update custom fields on all child records when updation of same fields on that field on parent occurs. using trigger
I have 2 custom objects: Student and Registration.They have a same field class. Registration has a lookup to Student. I need to update all related registration records's class field when the class of student is updated using triggers. (A student can have multiple registrations)
Thanks in advance.
Thanks in advance.
Please mark it as a best if it helps you.
Thanks,
Ajay Dubedi
All Answers
- Create a Process on Student__c object for everytime a record is created or edited.
- Use record update feature in Process Builder to update the class field on the child records (i.e Registration object records) .
- Activate the Process.
Please let me know if you have any more doubts.Please mark it as a best if it helps you.
Thanks,
Ajay Dubedi
It is always better to use out of the box functionality of Salesforce if that caters your requirement. But as you want to impement it via trigger please find the code below: Its better to use trigger framework but as of now I have just write the code in Trigger itself.
Thanks
Preyanka
- Less Maintenaince
- Easy Deployment
- Facilitates making changes easily
- No need of writing unit tests
It was for this main reason that Process was introduced. I always recommend Processes if possible.That being said, if you really want to know how the Trigger would look like - Like as mentioned by the other folks, you should never write the business logic within the Trigger. It becomes difficult to maintain and the order of execution becomes unpredictable. That being said, I have written it within the Trigger for the sake of simplicity. You should try using a Trigger Pattern which is easy for you to understand.
Good Luck!