Send an email concerning a task to ALL CENTRES if selected a decision box

Send an email concerning a task to ALL CENTRES if selected a decision box


Hello,

I have two databases: one concerning a list of centres (with several contact email for each centre) and another database concerning tasks that are assigned to these centres.

In the task form, there is a lookup dropdown menu for selecting the centre which the task is assigned to, and a decision box "Assign the task to all centres"

My doubt is how to get all the emails for all the centres, for including them in the "sendemail" function.

For the moment, I have this working:
// First, if the decision box "dirigida_a_todos" (assigned to all centres) is not selected and there is a centre selected in the dropdown menu, send the email to two contact email (Email and Email1) of the selected centre 
i
f((count(Alta_Centros[C_digo_del_Centro == input.Dirigida_a]) == 1) && input.Dirigida_a_todos == false)
{
matchingCentro = Alta_Centros[C_digo_del_Centro == input.Dirigida_a];
matchingEmailC=matchingCentro.Email;
matchingEmailD1=matchingCentro.Email1;
sendmail
[
from:zoho.adminuserid
to:matchingEmailC,matchingEmailD1
subject:"SUBJECT""
message:"MESSAGE"
]
}
else if(input.Dirigida_a_todos)
{
//I HAVE THE DOUBT HERE. How can I get all the emails of all centres and include them in the email?
    XXXXXXXXXXXXXXXXXXXXXX
sendmail
[
from:zoho.adminuserid
to: XXXXXXXXXXXXXXX
subject:"SUBJECT""
message:"MESSAGE"
]







}
















Thanks!