Custom Function for Milestone Auto-Complete

Custom Function for Milestone Auto-Complete

A custom function is a piece of software code that can help automate a process. Users can write their own Custom Functions using deluge and call them from a workflow. Let us take a look at how custom functions can help organizations manage their workflow.

Custom Functions can be used by organizations that want to automatically mark their milestones as complete once all of the tasks within the milestone have been completed. First we need to establish a connection, define a workflow rule and then associate a custom function to that workflow rule.

Create a new connection
  1. Navigate to the Setup icon and select Marketplace.
  2. Click Connections under Marketplace and then Create Connection.
  3. Click Default Services under Pick your service.
  4. Select Zoho Projects.
  5. Enter ZP MS Autocomplete as the Connection name and select the scopes ZohoProjects.milestones.UPDATE, ZohoProjects.bugs.READ, ZohoProjects.tasks.READ, and Zoho Projects.milestones.ALL

  6. Click the Create and Connect button.

  7. You will be prompted to connect to the newly established connection
  8. Click the Proceed button.

  9. The connection will be created once the accept button is clicked.

Note : Remember that 'Use Credentials of Login User' has to be switched off.

Workflow rule for automatically completing a milestone
  1. Click in the top navigation bar.
  2. Navigate to Task Automation and click Workflow Rules.
  3. Click New Workflow Rule.
  4. Enter the workflow name, description, and select the required layout.
  5. Under Execute on, choose 'Update' then Choose 'Field Specific and Select 'Status' from drop down menu.
  6. Click Next.

Create and associate the custom function to the workflow

Next, we will create a custom function and associate it with the workflow rule.
  1. Click on Add Action and then select Associate Custom Function.
  2. Click Create Custom Function in the Associate Custom Function page.

  3. In the Create Custom Function page type in the function name as Milestone Auto Complete.
  4. Add Arguments for project id, portal id, and milestone id as shown in the image below.

  5. Use this as the Sample Code and click Save.
  6. Associate the created Custom Function.

Click Save Rule.


  1. Sample Code: 
    1. // Construct parameter to filter the open tasks
      taskParam = Map();
      taskParam.put("status","notcompleted");
      taskParam.put("milestone_id",milestoneId);
      // Invoke get tasks API
      //Add your connection name as last parameter
      taskResponse = zoho.projects.getRecords(portalId,projectId,"tasks",taskParam,1,"zpmsautocomplete");
      info taskResponse;
      // Variable declaration and assign value , Endpoint of the API
      // This Varibale used to decide the milestone completion
      isMilestoneUpdate = false;
      // If task response is empty it will check any open bugs are available
      if(taskResponse.isEmpty())
      {
      // construct parameter for filter only open bugs
      milestoneList = list();
      milestoneList.add(milestoneId);
      bugParam = Map();
      bugParam.put("statustype","open");
      bugParam.put("milestone",milestoneList);
      info "bugParam:" + bugParam;
      //Add your connection name as last parameter
      bugResponse = zoho.projects.getRecords(portalId,projectId,"bugs",bugParam,1,"zpmsautocomplete");
      info bugResponse;
      if(bugResponse.isEmpty())
      {
      isMilestoneUpdate = true;
      }
      }
      info "TaskResponse Is Empty :" + taskResponse.isEmpty() + ", isMilestoneUpdate:" + isMilestoneUpdate;
      info "---------------------";
      if(!milestoneId.isNull() && isMilestoneUpdate)
      {
      //Modify the status of the milestone.(1 - notcompleted, 2 - completed)
      milestoneParam = Map();
      milestoneParam.put("status",2);
      info milestoneParam;
      info "---------------------";
      // Enter The Connection option Example : connection:"your_conection_name"
      updateMilestoneResponse = invokeurl
      [
      url :projectsAPIEndPoint + "/portal/" + portalId + "/projects/" + projectId + "/milestones/" + milestoneId + "/status/"
      type :POST
      parameters:milestoneParam
      connection:"zpmsautocomplete"
      ];
      info updateMilestoneResponse;
      info "-------------------------------------";
      } 
      return "success";
We hope you found this post to be helpful.
If you have any questions, please leave them in the comments section below or email us at support@zohoprojects.com.








                          Zoho Desk Resources

                          • Desk Community Learning Series


                          • Digest


                          • Functions


                          • Meetups


                          • Kbase


                          • Resources


                          • Glossary


                          • Desk Marketplace


                          • MVP Corner


                          • Word of the Day



                              Zoho Marketing Automation

                                      • Sticky Posts

                                      • Manage Documents with SharePoint Extension in Zoho Projects

                                        SharePoint is a digital platform to store and manage your documents. Multiple users can work on the same document simultaneously, which enhances your team's productivity. By installing the extension in Zoho Projects, users can access the documents seamlessly
                                      • Work agile in Zoho Projects! The much-awaited Zoho Sprints integration is in the making.

                                        Let your teams work in both classic and agile methodology using our integration with Zoho Sprints. We made sure you get the best of both worlds with this integration. You can scale through teams irrespective of what methodology they use and make sure they work with speed and flexibility. And, you can do it all from one place- Zoho Projects.  Why this integration is a benefit?  This integration mostly helps in managing classic and agile practices together. Most organizations use a mix of both classic
                                      • Announcing ZUG India Meet-ups - Interact with Zoho Projects & Sprints Experts in your city!

                                        Dear Users, We are happy to announce another round of Zoho Community User Meet-Ups in India. The initiative aims to bring together product users and experts to provide a platform where we can exchange ideas and share best practices. Our product teams
                                      • Issue Status Timeline in Zoho Projects

                                        Issue Status Timeline is a visual display of your issue's status updates. You can track the status of your issue by knowing when and who made the updates. Depending on your preference, these updates can be viewed either as a timeline or a list view. For
                                      • Introducing Projects 8.0 - Focusing on Ease-of-Use and New Features

                                        Hello everyone! It's time for the reveal of the 8th version of Zoho Projects! This year our focus has been on minimizing the learning curve and improving the ease-of-use of the tool, so anyone new to Projects can hit the ground running and existing users


                                      Manage your brands on social media



                                              Zoho TeamInbox Resources

                                                Zoho DataPrep Resources



                                                  Zoho CRM Plus Resources

                                                    Zoho Books Resources


                                                      Zoho Subscriptions Resources

                                                        Zoho Projects Resources


                                                          Zoho Sprints Resources


                                                            Qntrl Resources


                                                              Zoho Creator Resources


                                                                Zoho WorkDrive Resources



                                                                  Zoho Campaigns Resources

                                                                    Zoho CRM Resources

                                                                    • CRM Community Learning Series

                                                                      CRM Community Learning Series


                                                                    • Tips

                                                                      Tips

                                                                    • 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