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

Related objects query.
Hi guys,
I'm a newbee to Apex coding and I'm not long in my new role working on Salesforce admin and development. I'm just wondering if any of you kind people can help me with my following scenario.
I have 2 objects and I'm trying to figure out a way to perform a check (from Object A) on the status of a number of instances of the other object (Object B). Basically what I need to setup is a check that will change the status of Object A to complete, once the statuses of all instances of Object B are marked as complete.
My 2 objects are related through a lookup field that is on Object B, and it is a lookup field for Object A.
I hope my query makes sense. If any of you can provide me with some pointers on how to achieve what I'm looking for I would be very grateful.
Many thanks in advance for your help with this!
I suggest creating a trigger on Object B.
What I suggest is that whenever a record is updated on Object B to complete, run a query to check the status of all Object B records related to Object A. If all Object B records related to Object A is complete, update Object A to complete, else do nothing.
Hi Rustan,
Thanks for your suggestion. I have been having problems trying to get a list of status for all Object B records related to Object A but I haven't been successful. I'm wondering if you would have any sample code to achieve this as I am probably doing something wrong.
Thanks again for your help!
Don't know, are you going to use a trigger or any methods from a class, but think that logic will be like shown below:
Hope, it will be useful for you.