How to Use a Custom Action to Invoke a Function to Send SMS/Email to Users selected in a report?

How to Use a Custom Action to Invoke a Function to Send SMS/Email to Users selected in a report?

Hi Everyone,

I would love some help with the logic on how to accomplish sending SMS/Email to many users selected in a report, then using a custom action to invoke a function. Here is what I have:

My Report:


As you can see I have many "Users" (Email, phone etc.) for each row. When I create the custom action I cannot pass the ID of the user, instead I am limited to only pass the ID of the "Delivery Location". 

Question #1:
How do I create a "for each" loop that gets the ID's of the users after passing the ID of the Delivery Location?

Sending an SMS/EMail:
I am familiar with sending SMS/Email via deluge and I have done it sucessfully when I am sending one at a time. But I am using the OpenURL code to popup a text box where I enter the test I want to send as SMS. How do I do this so that I can send the same email/text to every person that is selected? Here is my current code...

  1. void SMS.sendsms(Setup_Customer_Contacts VCustomer)
  2. {
  3.     querystring = "";
  4.     for each cust in VCustomer
  5.     {
  6.         querystring = querystring + "custID=" + cust.ID + "&";
  7.     }
  8.     openUrl("#Form:SMS_Content?" + querystring, "popup window", "height=400,width=400");
  9. }
Then the code on the popup window is:
  1. l = input.custID;
  2. for each cust in l
  3. {
  4.     VCust  =  Setup_Customer_Contacts  [ID == cust];
  5.     if ((VCust.Active  =  "Yes")  &&  VCust.Method.contains("Text"))
  6.     {
  7.         CustomerSMS = twilio.sms.send("Desert_Fuels_SMS", VCust.Phone.toString(), input.smsbody);
  8.     }
  9.     openUrl("#Script:dialog.close", "same window");
  10. }
This works great to send one person one text. But I can't seem to get it to work to send the same text to many Contacts/users.

Question #2:
How do I modify the code so that it can work to send to multiple users?

Any help on this would be GREATLY appreciated. I'm stuck :(