Add Participant to Event on Creation

Add Participant to Event on Creation

What is the best way to add a new Participant to an Event when it is created from a Sales Order?

Here's the scenario:

Quote job, then convert to Sales Order.
Assign a technician to the Sales Order by setting a custom lookup field to a contact.
Create an Event for the Sales Order and save it.
Add the technician contact from the Sales Order to the Participants list in the Event, so they get notified via email.

Note: the technicians are not users, only contacts.


First, do you have a recommendation of how this could be done better?
Second, how can I accomplish this with a custom function used in a Workflow Rule? Can you post a Deluge snippet for how to add a participant to an Event?


EDIT: So I managed to write part of the script, but I can't figure out how to add a participant to the event using Deluge:

  1. //load event by id
  2. evt = zoho.crm.getRecordById("Events",input.eventId);

  3. //check assigned entity to ensure we're working with Sales Order
  4. if(evt.get("SEMODULE")  ==  "SalesOrders")
  5. {
  6. //load the sales order
  7. order = zoho.crm.getRecordById("SalesOrders",(evt.get("RELATEDTOID")).toLong());
  8. //get the tech contact
  9. techId=order.get("Tech_ID"); //custom Contact lookup field on Sales Order
  10. if(techId  !=  "")
  11. {
  12. tech = zoho.crm.getRecordById("Contacts",techId.toLong());
  13. //info tech;
  14. //now add the contact as a participant
  15. }
  16. }

Thank you!