Zoho FSM | Mark attendance in Zoho People using the Checked-in hours in FSM Mobile

Mark attendance in Zoho People using the Checked-in hours in Zoho FSM Mobile

Use case: Use the check-ins and check-outs in the Zoho FSM mobile app to log the user's attendance in Zoho People.
 
Follow the steps below to implement this usecase:
Step 1: Create a connection for Zoho People
Step 2: Create a custom function
Step 3: Create a workflow rule

Step 1: Create a connection for Zoho People

To use the Zoho People APIs via the invokeURL task in the custom function, you need to create a connection for Zoho FSM. To do so:
  1. Navigate to Setup > Developer Space > Connections and click Create Connection.



  2. Under the Default Services tab, select Zoho People.



  3. Perform the following and click Create And Connect:
    1. Enter the Connection Name as ZohoPeopleCon
      The Connection Link Name will be automatically populated.
    2. Disable Use Credentials Of Login User. If this is disabled, the connection will utilize the credentials of the connection owner.
    3. Select the Scopes ZOHOPEOPLE.announcement.ALL,  ZOHOPEOPLE.assessment.ALL, ZOHOPEOPLE.attendance.all, and ZOHOPEOPLE.automation.ALL



  4. Click Connect in the authentication page.



  5. Click Authorize in the Authorization page.



  6. Click Proceed.



  7. Click Accept in the Permissions page.

In the custom function, where the Zoho People API is used via the invokeURL task, use this Connection Link Name.

Step 2: Create a custom function

Create a custom function to mark attendance in Zoho People using the checked-in hours in Zoho FSM Mobile
  1. Navigate to Setup > Automation > Actions. Select the Deluge Functions tab and click Create Function.
  2. Enter the following details and click Save:
    1. Function Name: CheckInHoursAsAttendanceInPeople
    2. Module: Attendance Logs
    3. In the Deluge Script Editor, enter the following script:

      /*
       ------check-In time-----
      */
      Check_In_Time = attendance_log.get("Check_In_Time");
      Check_In_temp_time = Check_In_Time.getSuffix("T");
      Check_In_time_f = Check_In_temp_time.subString(0,8);
      Temp_Check_In_Time = Check_In_Time.toTime();
      Check_In_date = Temp_Check_In_Time.getDay().toLong();
      if(Check_In_date < 10)
      {
      Check_In_date = "0" + Check_In_date;
      }
      Check_In_month = Temp_Check_In_Time.getMonth().toLong();
      if(Check_In_month < 10)
      {
      Check_In_month = "0" + Check_In_month;
      }
      Check_In_year = Temp_Check_In_Time.getYear();
      Final_Check_In_Time = Check_In_date + "/" + Check_In_month + "/" + Check_In_year + " " + Check_In_time_f;
      /*
       ------check-out time-----
      */
      Check_Out_Time = attendance_log.get("Check_Out_Time");
      if(Check_Out_Time != null)
      {
      Check_Out_temp_time = Check_Out_Time.getSuffix("T");
      Check_Out_time_f = Check_Out_temp_time.subString(0,8);
      Temp_Check_Out_Time = Check_Out_Time.toTime();
      Check_Out_date = Temp_Check_Out_Time.getDay().toLong();
      if(Check_Out_date < 10)
      {
      Check_Out_date = "0" + Check_Out_date;
      }
      Check_Out_month = Temp_Check_Out_Time.getMonth().toLong();
      if(Check_Out_month < 10)
      {
      Check_Out_month = "0" + Check_Out_month;
      }
      Check_Out_year = Temp_Check_Out_Time.getYear();
      Final_Check_Out_Time = Check_Out_date + "/" + Check_Out_month + "/" + Check_Out_year + " " + Check_Out_time_f;
      }
      /*
       ------Owner Email-----
      */
      owner_map = attendance_log.get("Owner").toMap();
      owner_email = owner_map.get("email");
      /*
       ------People Check-In check-Out Code-----
      */
      if(Check_Out_Time == null)
      {
      paramMap = Map();
      paramMap.put("dateFormat","dd/MM/yyyy HH:mm:ss");
      paramMap.put("checkIn",Final_Check_In_Time);
      paramMap.put("emailId",owner_email);
      response = invokeurl
      [
      type :POST
      parameters:paramMap
      connection:"zohopeoplecon"
      ];
      }
      else
      {
      paramMap = Map();
      paramMap.put("dateFormat","dd/MM/yyyy HH:mm:ss");
      paramMap.put("checkOut",Final_Check_Out_Time);
      paramMap.put("emailId",owner_email);
      response = invokeurl
      [
      type :POST
      parameters:paramMap
      connection:"zohopeoplecon"
      ];
      info "response: " + response;
      }

Step 3: Create a workflow rule

Create a workflow rule in Zoho FSM to mark attendance in Zoho People using the checked-in hours in Zoho FSM Mobile
  1. Navigate to Setup > Automation > Workflow Rules and click Create Workflow.
  2. Enter the following details, then click Next:
    1. Module: Attendance Logs
    2. Rule Name: CheckInHoursAsAttendanceInPeople
    3. Description: Mark attendance in Zoho People using the checked-in hours in Zoho FSM Mobile



  3. Select the rule trigger as Created or Edited and click Next. Select the checkbox Repeat this workflow whenever a Attendance is edited.



  4. Select the rule criteria as To all Attendance. Click Next.



  5. Click +Action and select Function.



  6. Select Existing Functions and click Next.



  7. Select the custom function created in the last step.



  8. Click Save.


Testing the use case

Log in to Zoho FSM mobile and check-in. The checked-in time will reflect in Zoho People. Similarly, when you check-out, it will also reflect in Zoho People.
 


Please ensure that you haven't chosen any preferences for Push time log entries to attendance. You can find this option at Time Tracker > SettingsGeneral SettingsAttendance Integration Settings.