Zoho FSM | Create an event in Zoho Calendar for a Service Appointment

Create an event in Zoho Calendar for a Service Appointment

Use Case: Whenever a service appointment is dispatched in Zoho FSM, create an event in Zoho Calendar.
 
Step 1: Create a custom function  
Step 2: Create a workflow rule

Step 1: Create a custom function 

Add a custom function that will create an event in Zoho Calendar from a service appointment
  1. Navigate to Setup > Automation > Functions and click Create Function.



  2. Enter the following details and click Save:
    1. Function Name: CreateEventInZohoCalendar
    2. Module: Service Appointments
    3. In the Deluge Script Editor, enter the following script:

      sstart = service_appointment.get("Scheduled_Start_Date_Time");

      ssend = service_appointment.get("Scheduled_End_Date_Time");

      sstartarr = sstart.toList("T");

      newstart = sstartarr.get(0).replaceAll("-","") + "T" + sstartarr.get(1).replaceAll(":","");

      sendarr = ssend.toList("T");

      newend = sendarr.get(0).replaceAll("-","") + "T" + sendarr.get(1).replaceAll(":","");

      dateandtime_map = Map();

      dateandtime_map.put("start",newstart);

      dateandtime_map.put("end",newend);

      attendees_list = List();

      attendees_list.add({"email":"shawn@zylker.com"});

      attendees_list.add({"email":"hailee@zylker.com"});

      eventDetails = Map();

      eventDetails.put("estatus","added");

      eventDetails.put("title",service_appointment.get("Name"));

      eventDetails.put("dateandtime",dateandtime_map);

      eventDetails.put("isallday","true");

      eventDetails.put("attendees",attendees_list);

      event = Map();

      event.put("eventdata",eventDetails);

      info eventDetails;

      info zoho.calendar.createEvent("{calendarUid}",event);

Replace {calendarUid} with the actual value. To find the calendarUid, navigate to Settings > My Calendars > Integrate Calendar in Zoho Calendar.
 

 
Ensure that the status of the internal connection for Zoho Calendar integration task is Connected. The green dot [] indicates that it is Connected.
 

Step 2: Create a workflow rule 

Whenever a service appointment is dispatched in Zoho FSM, create an event in Zoho Calendar.
  1. Navigate to Setup > Automation > Workflow Rules and click Create Workflow.
  2. Enter the following details, then click Next:
    1. Module: Service Appointments
    2. Rule Name: Create Event in Zoho Calendar
    3. Description: Create an event in Zoho Calendar when a service appointment is dispatched



  3. Select the rule trigger as Created or Edited and click Next. Ensure that Repeat this workflow whenever a Service Appointment is edited is selected.



  4. Select the rule criteria as Only to the Service Appointment matching certain conditions and add the condition Status is Dispatched. Click Next.



  5. Click +Action and select Function.



  6. Select Existing Functions and click Next.



  7. Select the function created in the previous step.



  8. Click Save.


Testing the Use Case 

Create a service appointment and dispatch it. An event will be created in Zoho Calendar for the service appointment.