Create Timesheets in Zoho People from Zoho FSM Timesheets

Create Timesheets in Zoho People from Zoho FSM Timesheets

Use case: Whenever a timesheet is created in Zoho FSM, add a timesheet in Zoho People.

Follow the steps below to implement this use case:

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 People. To do so:
  1. In Zoho FSM, 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.employee.ALL,  ZOHOPEOPLE.employee.READ, ZOHOPEOPLE.forms.ALL, and ZOHOPEOPLE.timetracker.all



  4. Click Connect.



  5. Click Connect.



  6. 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 connection for Zoho FSM  

To use the Zoho FSM 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 FSM.



  3. Perform the following and click Create And Connect:
    1. Connection Name: FSMConnection
      The Connection Link Name will be populated automatically.
    2. Disable Use Credentials Of Login User.
    3. Select the Scopes ZohoFSM.users.READ.



  4. Click Connect.



  5. Click Accept in the Permissions page.


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


Step 3: Create a custom field

Create a custom field Zoho People Job ID of type single line in the Service Appointments module. Add this field to a new section. This field will be used to store the ID of the job in Zoho People for which the timesheet will be created.  Use the Api name in the custom function.


Step 4: Create a custom function   

Add a custom function that will create a timesheet in Zoho People from a timesheet in Zoho FSM.
  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: CreateTimesheetsInPeople
    2. Module: Time Sheets
    3. In the Deluge Script Editor, enter the following script: 

try

{

info time_sheet;

Assignees = "";

Sr_idlist = list();

sr_emailid_list = list();

time = toNumber(60);

Start_Date = time_sheet.get("Start_Date_Time").getPrefix("T");

End_Date = time_sheet.get("End_Date_Time");

if(!End_Date.isNull() && !End_Date.isEmpty())

{

End_Date = End_Date.getPrefix("T");

}

Job_name = time_sheet.get("Service_Appointment").get("name");

duration = time_sheet.get("Duration");

if(!duration.isNull() && !duration.isEmpty())

{

duration = duration.toNumber();

var = duration / time;

info var;

                                var=var.round(2);

time_sheetname = time_sheet.get("Name");

Sr_id = time_sheet.get("Service_Resource").toMap().get("id");

info Sr_id;

response = invokeurl

[

url :"https://fsm.zoho.com/fsm/v1/users"

type :GET

connection:"fsmconnection"

];

// info Sr_idlist;

usr_li = response.get("users").toList();

for each  sample in usr_li

{

usr_sr_id = sample.get("Service_Resources").get("id");

info usr_sr_id;

if(Sr_id == usr_sr_id)

{

sr_emailid = sample.get("email");

break;

}

}

//info time_sheet;

Service_appointment_id = time_sheet.get("Service_Appointment").get("id");

ser_app_resp = zoho.fsm.getRecordById("Service_Appointments",Service_appointment_id);

// info ser_app_resp;

job_id = ser_app_resp.get("data").toMap().get("zoho_People_job_Id__C");

if(job_id == null || job_id == "")

{

Service_Appointment_X_Service_Resources = ser_app_resp.get("data").toMap().get("$Service_Resources");

// info Service_Appointment_X_Service_Resources;

for each  Service_Resources in Service_Appointment_X_Service_Resources

{

Service_Resource_id = Service_Resources.toMap().get("id");

Sr_idlist.add(Service_Resource_id);

}

for each  sample in usr_li

{

usr_sr_id = sample.get("Service_Resources").get("id");

if(Sr_idlist.contains(usr_sr_id))

{

sr_emailid_list.add(sample.get("email"));

}

}

// info sr_emailid_list;

for each  email in sr_emailid_list

{

searchMap = Map();

searchMap.put("searchField","EmailID");

searchMap.put("searchOperator","Is");

searchMap.put("searchText",email);

response = zoho.people.getRecords("P_Employee",0,50,searchMap).toMap();

// info response;

if(response.contains("EmployeeID"))

{

Zoho_ID = response.get("Zoho_ID");

// info Zoho_ID;

if(Assignees != null && Assignees != "")

{

Assignees = Assignees + ";" + Zoho_ID;

}

else

{

Assignees = Zoho_ID;

}

}

}

// info Assignees;

if(Assignees != null && Assignees != "")

{

inputData = {"Job_Name":Job_name,"Assignees":Assignees};

info inputData;

response = zoho.people.create("P_TimesheetJob",inputData);

info response;

job_id = response.toMap().get("result").get("pkId");

info zoho.fsm.updateRecord("Service_Appointments",Service_appointment_id,{"zoho_People_job_Id__C":job_id});

}

}

info sr_emailid;

event = Map();

event.put("user",sr_emailid);

event.put("workDate",Start_Date);

event.put("jobId",job_id);

event.put("hours",var);

event.put("billingStatus","Billable");

info event;

response = invokeurl

[

url :"https://people.zoho.com/people/api/timetracker/addtimelog"

type :post

parameters:event

connection:"zohopeoplecon"

];

info response;

data = Map();

data.put("user",sr_emailid);

data.put("timesheetName",time_sheetname);

data.put("fromDate",Start_Date);

data.put("toDate",End_Date);

data.put("jobId",job_id);

info data;

response = invokeurl

[

url :"https://people.zoho.com/people/api/timetracker/createtimesheet"

type :post

parameters:data

connection:"zohopeoplecon"

];

info response;

}

}

catch (error)

{

info error;

// sendmail

// [

// from :zoho.adminuserid

// to :zoho.adminuserid

// subject :"Timesheet creation failed"

// message :error

// ]

}

Step 5: Create a workflow rule  

Create a workflow rule to create timesheets in Zoho People whenever timesheets are created in Zoho FSM.
  1. Navigate to Setup > Automation > Workflow Rules and click Create Workflow.
  2. Enter the following details, then click Next:
    1. Module: Time Sheets
    2. Rule Name: CreateTimesheetsInPeople
    3. Description: Create timesheets in Zoho People from timesheets in Zoho FSM



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



  4. Select the rule criteria as To all Time Sheets. 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  

Create a timesheet in Zoho FSM. A timesheet will be created in Zoho People for the user provided the user is present in Zoho People.


      Create. Review. Publish.

      Write, edit, collaborate on, and publish documents to different content management platforms.

      Get Started Now


        Access your files securely from anywhere

          Zoho CRM Training Programs

          Learn how to use the best tools for sales force automation and better customer engagement from Zoho's implementation specialists.

          Zoho CRM Training
            Redefine the way you work
            with Zoho Workplace

              Zoho DataPrep Personalized Demo

              If you'd like a personalized walk-through of our data preparation tool, please request a demo and we'll be happy to show you how to get the best out of Zoho DataPrep.

              Zoho CRM Training

                Create, share, and deliver

                beautiful slides from anywhere.

                Get Started Now


                  Zoho Sign now offers specialized one-on-one training for both administrators and developers.

                  BOOK A SESSION







                              Quick LinksWorkflow AutomationData Collection
                              Web FormsEnterpriseOnline Data Collection Tool
                              Embeddable FormsBankingBegin Data Collection
                              Interactive FormsWorkplaceData Collection App
                              CRM FormsCustomer ServiceAccessible Forms
                              Digital FormsMarketingForms for Small Business
                              HTML FormsEducationForms for Enterprise
                              Contact FormsE-commerceForms for any business
                              Lead Generation FormsHealthcareForms for Startups
                              Wordpress FormsCustomer onboardingForms for Small Business
                              No Code FormsConstructionRSVP tool for holidays
                              Free FormsTravelFeatures for Order Forms
                              Prefill FormsNon-Profit

                              Intake FormsLegal
                              Mobile App
                              Form DesignerHR
                              Mobile Forms
                              Card FormsFoodOffline Forms
                              Assign FormsPhotographyMobile Forms Features
                              Translate FormsReal EstateKiosk in Mobile Forms
                              Electronic Forms
                              Drag & drop form builder

                              Notification Emails for FormsAlternativesSecurity & Compliance
                              Holiday FormsGoogle Forms alternative GDPR
                              Form to PDFJotform alternativeHIPAA Forms
                              Email FormsFormstack alternativeEncrypted Forms

                              Wufoo alternativeSecure Forms

                              TypeformWCAG


                                          Create. Review. Publish.

                                          Write, edit, collaborate on, and publish documents to different content management platforms.

                                          Get Started Now




                                                            You are currently viewing the help pages of Qntrl’s earlier version. Click here to view our latest version—Qntrl 3.0's help articles.




                                                                Manage your brands on social media


                                                                  • Desk Community Learning Series


                                                                  • Digest


                                                                  • Functions


                                                                  • Meetups


                                                                  • Kbase


                                                                  • Resources


                                                                  • Glossary


                                                                  • Desk Marketplace


                                                                  • MVP Corner


                                                                  • Word of the Day


                                                                  • Ask the Experts


                                                                    Zoho Sheet Resources

                                                                     

                                                                        Zoho Forms Resources


                                                                          Secure your business
                                                                          communication with Zoho Mail


                                                                          Mail on the move with
                                                                          Zoho Mail mobile application

                                                                            Stay on top of your schedule
                                                                            at all times


                                                                            Carry your calendar with you
                                                                            Anytime, anywhere




                                                                                  Zoho Sign Resources

                                                                                    Sign, Paperless!

                                                                                    Sign and send business documents on the go!

                                                                                    Get Started Now




                                                                                            Zoho TeamInbox Resources





                                                                                                      Zoho DataPrep Demo

                                                                                                      Get a personalized demo or POC

                                                                                                      REGISTER NOW


                                                                                                        Design. Discuss. Deliver.

                                                                                                        Create visually engaging stories with Zoho Show.

                                                                                                        Get Started Now








                                                                                                                            • Related Articles

                                                                                                                            • Zoho FSM Mobile App

                                                                                                                              The Zoho FSM mobile app empowers on-the-go field agents with all the information they need, to be efficient at work and delight contacts with every appointment. It helps them to be on time for their appointments, attend more appointments in a single ...
                                                                                                                            • Push Zoho FSM Contacts to Google Contacts

                                                                                                                              Use case: Push (create/update) a Zoho FSM contact to Google Contacts. Changes made to the Name, Email, Mobile, Phone, or Service Address of the Zoho FSM Contact will reflect in the corresponding Google Contact. Follow the steps below to implement ...
                                                                                                                            • Overview of Zoho FSM

                                                                                                                              What is Zoho FSM? Zoho FSM is a cloud application that offers an overarching solution for handling the entire life cycle of processes involved in the management and execution of field services. All processes that are pivotal to field services are ...
                                                                                                                            • Create Requests in Zoho FSM from Zoho CRM Deals

                                                                                                                              Usecase: Using a custom button, push Deals in Zoho CRM as Requests to Zoho FSM. Step 1: Create a connection for Zoho FSM in Zoho CRM Step 2: Create a custom button Step 3: Create a custom function Step 1: Create a connection for Zoho FSM in Zoho CRM ...
                                                                                                                            • How do I create a new user in Zoho FSM?

                                                                                                                              To create a new user in Zoho FSM: Under Workforce, select Users. Click the + New User button. Fill in the user’s details: Last Name, Email Address, and Profile are mandatory fields. Click Save. Once saved, the user's status will be set to Invited. An ...
                                                                                                                              Wherever you are is as good as
                                                                                                                              your workplace

                                                                                                                                Resources

                                                                                                                                Videos

                                                                                                                                Watch comprehensive videos on features and other important topics that will help you master Zoho CRM.



                                                                                                                                eBooks

                                                                                                                                Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho CRM.



                                                                                                                                Webinars

                                                                                                                                Sign up for our webinars and learn the Zoho CRM basics, from customization to sales force automation and more.



                                                                                                                                CRM Tips

                                                                                                                                Make the most of Zoho CRM with these useful tips.



                                                                                                                                  Zoho Show Resources