You need to sign in to do that
Don't have an account?
Is this something that can be done with a trigger?
One of my customers sent me the following:
"We have a child object connected to Opportunities that is pretty simple – it consists of a couple of text fields, a date. Reps use it to record “next steps” for opportunities. What we need is the latest “Next Step” created related to an opportunity to populate a field on the parent opportunity with one of its text fields. This way, the latest “Next Step” can be included in reports along with opportunities and their products. I still haven’t looked into it too much but if it’s possible, I believe it’ll have to be a trigger. I guess the high level requirement here is we want to record next steps as deals progress but we also want the latest one – and only the latest one – to fit into a funnel report that is used to manage calls, etc."
"We have a child object connected to Opportunities that is pretty simple – it consists of a couple of text fields, a date. Reps use it to record “next steps” for opportunities. What we need is the latest “Next Step” created related to an opportunity to populate a field on the parent opportunity with one of its text fields. This way, the latest “Next Step” can be included in reports along with opportunities and their products. I still haven’t looked into it too much but if it’s possible, I believe it’ll have to be a trigger. I guess the high level requirement here is we want to record next steps as deals progress but we also want the latest one – and only the latest one – to fit into a funnel report that is used to manage calls, etc."
Your trigger will fire when a new Next Step record is inserted, and the trigger will have to query all the Next Step records for the opportunity and sort them by created date and limit to 1. The trigger can then use the info that the query returned and update the opp.
I hope this helps?
this might be close to what you need -
You might need an after update trigger, but I didn't account for that. Plus you'll need a test class. I just took a swag at it.