+ Start a Discussion
Cris9931Cris9931 

query all the related records(dispatchers) to a Service Team

Hi, I have two objects.

Dispatcher(SVMXC__Dispatcher_Access__c) and Service Team(SVMXC__Service_Group__c).

The relationship between Dispatcher and the Service Team is many to one, in other words there can be multiple dispatchers associated to one Service Team. 

Here is a picture to make you understand:For example, we have this team AP-S-Indonesia FSE and we have 6 dispatchers related to this Service Team.
User-added image

I want to create a trigger to fetch all the Dispatchers related to this Service Team. Any suggestions?

Best Answer chosen by Cris9931
ShirishaShirisha (Salesforce Developers) 
Hi Cristian,

Greetings!

You can use the below format for standard objects:

1) select id, (select id from SVMXC__Dispatcher_Access__r) from SVMXC__Service_Group__c
Which gives you a list of parent objects with their corresponding child objects. You should use the plural of the child object (childobject becomes childobjects).

Kindly mark it as best answer if it helps so that it can help others in the future.

Warm Regards,
Shirisha Pathuri

 

All Answers

ShirishaShirisha (Salesforce Developers) 
Hi Cristian,

Greetings!

You can use the below format for standard objects:

1) select id, (select id from SVMXC__Dispatcher_Access__r) from SVMXC__Service_Group__c
Which gives you a list of parent objects with their corresponding child objects. You should use the plural of the child object (childobject becomes childobjects).

Kindly mark it as best answer if it helps so that it can help others in the future.

Warm Regards,
Shirisha Pathuri

 
This was selected as the best answer
Cris9931Cris9931
Thank you! :)