Power of Automation :: Automatically approve the pending timelogs at your preferred time

Power of Automation :: Automatically approve the pending timelogs at your preferred time

Hello Everyone,


A custom function is a software code that can be used to automate a process and this allows you to automate a notification, call a webhook, or perform logic immediately after a workflow rule is triggered. This feature helps to automate complex tasks and calculations. 


Below is the requirement:


Our customer approached with the below requirement - They want an automation that all the pending timelogs should be automatically approved in the first week of every month. Likewise, it is possible to configure as per your preferred time.

We had accomplished this requirement using Schedule functions. This allows you to execute custom functions based on a specified schedule such as hourly, daily, weekly, or monthly. This feature can be used for recurring actions, like generating monthly reports or sending automated emails to portal users about upcoming public milestones or deadlines without relying on specific events.


Create a connection for the Zoho Projects service with the scopes "ZohoProjects.timesheets.ALL' to replace ‘projects’ with the connection name. Click this link below to learn how to create the connection. Attached a screenshot of the Schedule Function for reference.


Script to be used:


endPointV3 = "https://projects.zoho.com/api/v3/portal/";

logParamList = List();

moduleTemplate = Map();

moduleTemplate.put("type","task");

timesheetParam = Map();

timesheetParam.put("view_type","month");

timesheetParam.put("module",moduleTemplate);

timesheetParam.put("start_date",zoho.currentdate.addMonth(-1));

timesheetParam.put("end_date",zoho.currentdate);

taskTimesheetResponse = invokeurl

[

url :endPointV3 + portalId + "/timesheet"

type :GET

parameters:timesheetParam

connection:"projects"

];

// info taskTimesheetResponse;

if(taskTimesheetResponse != null)

{

for each  time_log in taskTimesheetResponse.get("time_logs")

{

for each  logs in time_log.get("log_details")

{

logDetail = Map();

logDetail.put("approval_status","approved");

logDetail.put("module","task");

logDetail.put("id",logs.get("id"));

logParamList.add(logDetail);

}

}

}

genralLogIds = Map();

moduleTemplate.clear();

timesheetParam.remove("module");

moduleTemplate.put("type","general");

timesheetParam.put("module",moduleTemplate);

generalTimesheetResponse = invokeurl

[

url :endPointV3 + portalId + "/timesheet"

type :GET

parameters:timesheetParam

connection:"projects"

];

// info generalTimesheetResponse;

if(generalTimesheetResponse != null)

{

for each  time_log in generalTimesheetResponse.get("time_logs")

{

for each  logs in time_log.get("log_details")

{

logDetail = Map();

logDetail.put("approval_status","approved");

logDetail.put("module","general");

logDetail.put("id",logs.get("id"));

logParamList.add(logDetail);

}

}

}

issueLogIds = Map();

moduleTemplate.clear();

timesheetParam.remove("module");

moduleTemplate.put("type","issue");

timesheetParam.put("module",moduleTemplate);

issueTimesheetResponse = invokeurl

[

url :endPointV3 + portalId + "/timesheet"

type :GET

parameters:timesheetParam

connection:"projects"

];

// info issueTimesheetResponse;

if(issueTimesheetResponse != null)

{

for each  time_log in issueTimesheetResponse.get("time_logs")

{

for each  logs in time_log.get("log_details")

{

logDetail = Map();

logDetail.put("approval_status","approved");

logDetail.put("module","issue");

logDetail.put("id",logs.get("id"));

logParamList.add(logDetail);

}

}

}

approveTimesheets = invokeurl

[

url :endPointV3 + portalId + "/logs"

type :PATCH

parameters: "["+logParamList.toString()+"]"

connection:"projects"

];

info approveTimesheets;

Creating custom functions in Zoho Projects is straightforward and well-documented. Zoho provides a range of built-in functions that you can use as a starting point, and you can also easily define your own functions using Zoho's scripting language, Deluge. Give it a try and see how it can save your time and boost your productivity!

 

Watch this space for more such custom function codes. 


    Access your files securely from anywhere







                            Zoho Developer Community





                                                  Use cases

                                                  Make the most of Zoho Desk with the use cases.

                                                   
                                                    

                                                  eBooks

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

                                                   
                                                    

                                                  Videos

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

                                                   
                                                    

                                                  Webinar

                                                  Sign up for our webinars and learn the Zoho Desk basics, from customization to automation and more

                                                   
                                                    
                                                  • Desk Community Learning Series


                                                  • Meetups


                                                  • Ask the Experts


                                                  • Kbase


                                                  • Resources


                                                  • Glossary


                                                  • Desk Marketplace


                                                  • MVP Corner




                                                            • Sticky Posts

                                                            • Schedule Exports for Regular Project Updates

                                                              Tracking project data often means exporting data at regular intervals. Instead of manually exporting data every time, users can schedule exports for Phases, Tasks, and Tasks in Zoho Projects. These exports can be set to run once, daily, weekly, or monthly
                                                            • Set Custom Business Calendars and Holidays for Global Teams

                                                              Managing a project across diverse teams means accounting for more than just tasks and deadlines; it means acknowledging how and when each team actually works. Users might follow different working days or observe region-specific holidays that cannot be
                                                            • Introducing Version-3 APIs - Explore New APIs & Enhancements

                                                              Happy to announce the release of Version 3 (V3) APIs with an easy to use interface, new APIs, and more examples to help you understand and access the APIs better. V3 APIs can be accessed through our new link, where you can explore our complete documentation,
                                                            • Restore Trashed Records Anytime Within 30 Days

                                                              Access the recycle bin from the Data Administration tab under the settings page in Zoho Projects, which gives better control over the trashed data. When records like projects, phases, task lists, tasks, issues, or project templates are trashed, they are
                                                            • Organize and Clone Task Custom Views

                                                              We have rolled out two new enhancements to task custom views: Custom View Groups and Custom View Clone. Custom View Groups Similar to predefined view groups, we have introduced groups for custom views to help organize and categorize them. My Custom Views:


                                                            Manage your brands on social media



                                                                  Zoho TeamInbox Resources



                                                                      Zoho CRM Plus Resources

                                                                        Zoho Books Resources


                                                                          Zoho Subscriptions Resources

                                                                            Zoho Projects Resources


                                                                              Zoho Sprints Resources


                                                                                Qntrl Resources


                                                                                  Zoho Creator Resources



                                                                                      Zoho CRM Resources

                                                                                      • CRM Community Learning Series

                                                                                        CRM Community Learning Series


                                                                                      • Kaizen

                                                                                        Kaizen

                                                                                      • Functions

                                                                                        Functions

                                                                                      • Meetups

                                                                                        Meetups

                                                                                      • Kbase

                                                                                        Kbase

                                                                                      • Resources

                                                                                        Resources

                                                                                      • Digest

                                                                                        Digest

                                                                                      • CRM Marketplace

                                                                                        CRM Marketplace

                                                                                      • MVP Corner

                                                                                        MVP Corner







                                                                                          Design. Discuss. Deliver.

                                                                                          Create visually engaging stories with Zoho Show.

                                                                                          Get Started Now


                                                                                            Zoho Show Resources


                                                                                              Zoho Writer Writer

                                                                                              Get Started. Write Away!

                                                                                              Writer is a powerful online word processor, designed for collaborative work.

                                                                                                Zoho CRM コンテンツ








                                                                                                  Nederlandse Hulpbronnen


                                                                                                      ご検討中の方