You need to sign in to do that
Don't have an account?
Phuc Nguyen 18
Update Parent with comment field from every child record Class
Hello,
I am familiar with updaing a Parent record with a field from a child but not sure how to update the parent with a vlaue from each child.
There is a comment__c field on each Task__c record.
If there are 3 task associated to the Parent(export__c) I need the comment field on the Parent to house the comment from each child
For example:
task 1 comment = test for price
task 2 comment = ask for quote
task 3 comment = sending invoice
The commen ton the parent needs to look llike
test for price
ask for quote
sending invoice
No sure how to grab the values and then force a line break between each.
The relationship between the 2 objects is a lookup.
I would like to add this method into an existing class
Thanks,
P
I am familiar with updaing a Parent record with a field from a child but not sure how to update the parent with a vlaue from each child.
There is a comment__c field on each Task__c record.
If there are 3 task associated to the Parent(export__c) I need the comment field on the Parent to house the comment from each child
For example:
task 1 comment = test for price
task 2 comment = ask for quote
task 3 comment = sending invoice
The commen ton the parent needs to look llike
test for price
ask for quote
sending invoice
No sure how to grab the values and then force a line break between each.
The relationship between the 2 objects is a lookup.
I would like to add this method into an existing class
Thanks,
P
Please try the below code:
You don't need to clear the field separately as we are already declaring variable expComments with a blank value and assigning it to Comments__c after adding values to it.
Please try the above code. Let me know if any problem arises.
Regards
Ayush Sharma
All Answers
I have made a code for you, try to adjust this inside your existing code.
If any problem arises let me know.
Ayush
Hello Ayush,
Should this be in a before or after update?
I am assuming an update since the comment is enered after the Task is created?
Do I need to clear the comment field on the parent record before inserting the new comment(s)?
I am assuming this will also work in an after delete?
Thanks,
P
Please try the below code:
You don't need to clear the field separately as we are already declaring variable expComments with a blank value and assigning it to Comments__c after adding values to it.
Please try the above code. Let me know if any problem arises.
Regards
Ayush Sharma