You need to sign in to do that
Don't have an account?
Josh Schwerdtfeger
passing custom object id into the SOQL query
I have Opportunity as the parent object to a custom object Course. I want to build a soql that updates through a trigger a field on the course object, specific to each course. This is what i've got so far but i am not finding how to pass the course object into the where of the query. Any help would be great.
trigger WonNov on Course__c (before update) { AggregateResult[] groupedResults = [ Select SUM (Amount) sum from Opportunity WHERE Courseid__c = :recordId]; for (Course__c obj : Trigger.new) { double sum = double.valueOf(groupedResults[0].get('sum')); obj.Won_Nov_Outings__c = decimal.valueOf(sum); } }
Let us know if this will help you
All Answers
Let us know if this will help you
This is great, but i'm getting an error : "field 'Courseid__c' can not be grouped in a query call"
Idea is posted for same "Allow SOQL GROUP BY on formula fields"
1) https://success.salesforce.com/ideaView?id=08730000000HlNtAAK
Try to group by some other field.
This is great and i pulled and grouped by a different field and it works! Thank you!