+ Start a Discussion
subodh chaturvedi 17subodh chaturvedi 17 

i want to create a SOQL Query to count the Records and update in child Object field

I want to Create a SOQL Query to get the Count of number of Opportunity Records & update in child Object Field
Hi 
I have a requirement Where i want to Query the Records based on the Below Criteria :
Account_Executive is  a Custom Field(User Lookup) field whenever i select a User in Account_Executive field  in Territory_plan__c (object) it should query all the Records of event related to Opportunity  & update in  #of ONsite at xyz - in progress .
#of ONsite at xyz - in progress  : Is a field on Custom Object(Territory_plan__c ) where i want to Update the Count of below criteria

# of Onsite at xyz– In Progress
This field should populate with the number of Opportunity records that meet the following criteria:
The User in the “Account Executive” field in the Territory Plan object is equal to the “Assigned To” in the Event object
The Status for the Event is “Scheduled”
The Type for the Event is “On-Site at xyz”
pconpcon
Not knowing your exact object structure, can you do this with a rollup summary on the parent object and then if you want to display it on the child object, then do a formula field that is just the lookup to the rollup summary on the parent?

If not, please provide any code that you have written to do this and we can try to help you work through any problems you have.  These forums are not meant for posting stuff you need done and having people write the code for you.