For Zoho services only


I'm currently part of a wider delivery team at Ascent Business Solutions, recognised as a leading Zoho Premium Solutions Partner in the United Kingdom.

Ascent Business Solutions support organisations with everything from targeted technical fixes through to full Zoho CRM implementations and long-term platform adoption. Working as a team rather than a one-person consultancy allows projects to move forward consistently, with access to the right skills at each stage.

The team I manage specialises in API integrations between Zoho and third-party finance and commerce platforms such as Xero, Shopify, WooCommerce, and eBay. Much of our work involves solving integration challenges that fall outside standard documentation, supporting new ideas, new sectors, and evolving business models.

Success is measured through practical outcomes and return on investment, ranging from scaling small operations into high-turnover businesses to delivering rapid gains through online payments, automation, and streamlined digital workflows.

If you are looking for structured Zoho expertise backed by an established consultancy, you can contact Ascent Business Solutions on 0121 392 8140 (UK), email info@ascentbusiness.co.uk, or visit https://www.ascentbusiness.co.uk.
Zoho Projects: Add a Time Log to an Issue using Deluge

Zoho Projects: Add a Time Log to an Issue using Deluge

What?
This is an article to demonstrate how to log a time event under a Zoho Projects Issue using code (Zoho Deluge) rather than the graphical user interface (GUI). Note this would probably be similar to when trying to enter a time against a project Task but this article is focused on getting this working against Project Issues. Also note, we will refer to Project Issues in this article, but in the backend code, Zoho refer to Issues as "Bugs".

Why?
At time of this article (Apr-2021), we could not find a working example that could allow us to do this. I have provided some links at the end of this article for you which we tried to use but only helped us out about half-way, the rest we guessed on our own:
Zoho Projects - Add Time Log to an Issue Using Deluge - Projects Issue Time Log
Our use case, is that we are developing a Zoho Creator app that will help staff log time and then push the creator record to Zoho Projects.

How?
For the following example, you will need to have setup a Zoho Oauth Connection with the appropriate authorized scopes and have access to all related systems such as Zoho Projects and the originating app (in this example, Zoho Creator).

1. Setup up Zoho Oauth Connection:
  1. Go to connections (in creator this is icon in top-left > Setup > Connections)
  2. Click on "Add Connection" and click on "Zoho OAuth"
  3. Give a lower connection name, eg. "joels_connector"
  4. Select the scope ZohoProjects.timesheets.ALL as a minimum (or CREATE/READ):
    Zoho Projects - Add Time Log to an Issue Using Deluge - Connection

2. Code to push Time Log entry to Zoho Projects:
  1. Example #1: Pushing a time log with a specified start date/time (requires end time field if using):
    copyraw
    //
    // init (from dropdowns you have made applicable to your Zoho Projects system)
    v_PortalID = ifnull(input.ZohoProject_Portal,0);
    v_ProjectID = ifnull(input.ZohoProject_Project,0);
    v_IssueID = ifnull(input.ZohoProject_Issue,0);
    //
    // get data from form
    v_StartTime = ifnull(input.Start_Time.toTime(),zoho.currenttime);
    v_EndTime = ifnull(input.End_Time.toTime(),zoho.currenttime.addHour(1));
    v_Billable = if(input.Billing == "Paid", "Billable", "Non Billable");
    v_WorkNotes = ifnull(input.Work_Notes,"");
    v_TaskOrIssue = if(input.Type == "Task", "tasks", "bugs");
    //
    // eval
    v_HoursDecimal = (v_EndTime.toLong() - v_StartTime.toLong()) / 1000 / 60 / 60;
    v_TimeHour = ((v_EndTime.toLong() - v_StartTime.toLong()) / 1000 / 60 / 60).round(0).leftpad(2).replaceAll(" ", "0");
    v_TimeMinutes = ((v_EndTime.toLong() - v_StartTime.toLong()) / 1000 / 60 % 60).round(0).leftpad(2).replaceAll(" ", "0");
    v_HoursHHmm = v_TimeHour + ":" + v_TimeMinutes;
    //
    // build map
    m_CreateTimeLog = Map();
    m_CreateTimeLog.put("date",v_StartTime.toDate().toString("MM-dd-yyyy"));
    m_CreateTimeLog.put("bill_status",v_Billable);
    m_CreateTimeLog.put("hours",v_HoursHHmm);
    m_CreateTimeLog.put("start_time",v_StartTime.toString("hh:mm a"));
    m_CreateTimeLog.put("end_time",v_EndTime.toString("hh:mm a"));
    m_CreateTimeLog.put("notes",v_WorkNotes);
    v_Url = "https://projects.zoho.eu/restapi/portal/"+v_PortalID+"/projects/"+v_ProjectID+"/"+v_TaskOrIssue+"/"+v_IssueID+"/logs/";
    r_CreateTimeLog = invokeurl
    [
    	url :v_Url
    	type :POST
    	parameters:m_CreateTimeLog
    	connection:"joels_connector"
    ];
    info r_CreateTimeLog;
    1.  // 
    2.  // init (from dropdowns you have made applicable to your Zoho Projects system) 
    3.  v_PortalID = ifnull(input.ZohoProject_Portal,0)
    4.  v_ProjectID = ifnull(input.ZohoProject_Project,0)
    5.  v_IssueID = ifnull(input.ZohoProject_Issue,0)
    6.  // 
    7.  // get data from form 
    8.  v_StartTime = ifnull(input.Start_Time.toTime(),zoho.currenttime)
    9.  v_EndTime = ifnull(input.End_Time.toTime(),zoho.currenttime.addHour(1))
    10.  v_Billable = if(input.Billing == "Paid", "Billable", "Non Billable")
    11.  v_WorkNotes = ifnull(input.Work_Notes,"")
    12.  v_TaskOrIssue = if(input.Type == "Task", "tasks", "bugs")
    13.  // 
    14.  // eval 
    15.  v_HoursDecimal = (v_EndTime.toLong() - v_StartTime.toLong()) / 1000 / 60 / 60
    16.  v_TimeHour = ((v_EndTime.toLong() - v_StartTime.toLong()) / 1000 / 60 / 60).round(0).leftpad(2).replaceAll(" ", "0")
    17.  v_TimeMinutes = ((v_EndTime.toLong() - v_StartTime.toLong()) / 1000 / 60 % 60).round(0).leftpad(2).replaceAll(" ", "0")
    18.  v_HoursHHmm = v_TimeHour + ":" + v_TimeMinutes; 
    19.  // 
    20.  // build map 
    21.  m_CreateTimeLog = Map()
    22.  m_CreateTimeLog.put("date",v_StartTime.toDate().toString("MM-dd-yyyy"))
    23.  m_CreateTimeLog.put("bill_status",v_Billable)
    24.  m_CreateTimeLog.put("hours",v_HoursHHmm)
    25.  m_CreateTimeLog.put("start_time",v_StartTime.toString("hh:mm a"))
    26.  m_CreateTimeLog.put("end_time",v_EndTime.toString("hh:mm a"))
    27.  m_CreateTimeLog.put("notes",v_WorkNotes)
    28.  v_Url = "https://projects.zoho.eu/restapi/portal/"+v_PortalID+"/projects/"+v_ProjectID+"/"+v_TaskOrIssue+"/"+v_IssueID+"/logs/"
    29.  r_CreateTimeLog = invokeurl 
    30.  [ 
    31.      url :v_Url 
    32.      type :POST 
    33.      parameters:m_CreateTimeLog 
    34.      connection:"joels_connector" 
    35.  ]
    36.  info r_CreateTimeLog; 
  2. Example #2: Pushing a time log defaulting to the current time as start time:
    copyraw
    //
    // init (from dropdowns you have made applicable to your Zoho Projects system)
    v_PortalID = ifnull(input.ZohoProject_Portal,0);
    v_ProjectID = ifnull(input.ZohoProject_Project,0);
    v_IssueID = ifnull(input.ZohoProject_Issue,0);
    //
    // get data from form
    v_StartTime = ifnull(input.Start_Time.toTime(),zoho.currenttime);
    v_EndTime = ifnull(input.End_Time.toTime(),zoho.currenttime.addHour(1));
    v_Billable = if(input.Billing == "Paid", "Billable", "Non Billable");
    v_WorkNotes = ifnull(input.Work_Notes,"");
    v_TaskOrIssue = if(input.Type == "Task", "tasks", "bugs");
    //
    // eval
    v_HoursDecimal = (v_EndTime.toLong() - v_StartTime.toLong()) / 1000 / 60 / 60;
    v_TimeHour = ((v_EndTime.toLong() - v_StartTime.toLong()) / 1000 / 60 / 60).round(0).leftpad(2).replaceAll(" ", "0");
    v_TimeMinutes = ((v_EndTime.toLong() - v_StartTime.toLong()) / 1000 / 60 % 60).round(0).leftpad(2).replaceAll(" ", "0");
    v_HoursHHmm = v_TimeHour + ":" + v_TimeMinutes;
    //
    // build map
    m_CreateTimeLog = Map();
    m_CreateTimeLog.put("date",v_StartTime.toDate().toString("MM-dd-yyyy"));
    m_CreateTimeLog.put("bill_status",v_Billable);
    m_CreateTimeLog.put("hours",v_HoursHHmm);
    m_CreateTimeLog.put("notes",v_WorkNotes);
    v_Url = "https://projects.zoho.eu/restapi/portal/"+v_PortalID+"/projects/"+v_ProjectID+"/"+v_TaskOrIssue+"/"+v_IssueID+"/logs/";
    r_CreateTimeLog = invokeurl
    [
    	url :v_Url
    	type :POST
    	parameters:m_CreateTimeLog
    	connection:"joels_connector"
    ];
    info r_CreateTimeLog;
    1.  // 
    2.  // init (from dropdowns you have made applicable to your Zoho Projects system) 
    3.  v_PortalID = ifnull(input.ZohoProject_Portal,0)
    4.  v_ProjectID = ifnull(input.ZohoProject_Project,0)
    5.  v_IssueID = ifnull(input.ZohoProject_Issue,0)
    6.  // 
    7.  // get data from form 
    8.  v_StartTime = ifnull(input.Start_Time.toTime(),zoho.currenttime)
    9.  v_EndTime = ifnull(input.End_Time.toTime(),zoho.currenttime.addHour(1))
    10.  v_Billable = if(input.Billing == "Paid", "Billable", "Non Billable")
    11.  v_WorkNotes = ifnull(input.Work_Notes,"")
    12.  v_TaskOrIssue = if(input.Type == "Task", "tasks", "bugs")
    13.  // 
    14.  // eval 
    15.  v_HoursDecimal = (v_EndTime.toLong() - v_StartTime.toLong()) / 1000 / 60 / 60
    16.  v_TimeHour = ((v_EndTime.toLong() - v_StartTime.toLong()) / 1000 / 60 / 60).round(0).leftpad(2).replaceAll(" ", "0")
    17.  v_TimeMinutes = ((v_EndTime.toLong() - v_StartTime.toLong()) / 1000 / 60 % 60).round(0).leftpad(2).replaceAll(" ", "0")
    18.  v_HoursHHmm = v_TimeHour + ":" + v_TimeMinutes; 
    19.  // 
    20.  // build map 
    21.  m_CreateTimeLog = Map()
    22.  m_CreateTimeLog.put("date",v_StartTime.toDate().toString("MM-dd-yyyy"))
    23.  m_CreateTimeLog.put("bill_status",v_Billable)
    24.  m_CreateTimeLog.put("hours",v_HoursHHmm)
    25.  m_CreateTimeLog.put("notes",v_WorkNotes)
    26.  v_Url = "https://projects.zoho.eu/restapi/portal/"+v_PortalID+"/projects/"+v_ProjectID+"/"+v_TaskOrIssue+"/"+v_IssueID+"/logs/"
    27.  r_CreateTimeLog = invokeurl 
    28.  [ 
    29.      url :v_Url 
    30.      type :POST 
    31.      parameters:m_CreateTimeLog 
    32.      connection:"joels_connector" 
    33.  ]
    34.  info r_CreateTimeLog; 
You will find I've included the Hours decimal calculation above but it's not used and just for future reference. The API wants the total hours and minutes in the format "HH:mm" (eg. "34:06" = 34 hours and 6 minutes).

Error(s)
  • Input Parameter Missing (6831):
    Can happen when there are either too many parameters or one is missing. Instead of abiding by the API documentation which was out of date at time of print, trial and error will resolve this or use our examples above.
    copyraw
    // fields required if submitting time log without start time (uses current time and adds hours to it)
    - date          (in US format irrespective of your datacenter: MM-dd-yyyy)
    - bill_status   (either "Billable" or "Non Billable")
    - hours         (eg. "01:00")
    - notes         (the actual work notes: eg. "Twiddled thumbs and spun on chair")
    
    // fields required if submitting time lot with a start date/time
    - date        (in US format irrespective of your datacenter: MM-dd-yyyy this is also to be the start date of the time entry)
    - bill_status (either "Billable" or "Non Billable")
    - start_time  (eg. "01:00 PM" - note you will get error if you try to submit "13:00 PM")
    - end_time    (required because of start_time, also in format "02:00 PM")
    - notes       (the actual work notes: eg. "Twiddled thumbs and spun on chair")
    1.  // fields required if submitting time log without start time (uses current time and adds hours to it) 
    2.  - date          (in US format irrespective of your datacenter: MM-dd-yyyy) 
    3.  - bill_status   (either "Billable" or "Non Billable") 
    4.  - hours         (eg. "01:00") 
    5.  - notes         (the actual work notes: eg. "Twiddled thumbs and spun on chair") 
    6.   
    7.  // fields required if submitting time lot with a start date/time 
    8.  - date        (in US format irrespective of your datacenter: MM-dd-yyyy this is also to be the start date of the time entry) 
    9.  - bill_status (either "Billable" or "Non Billable") 
    10.  - start_time  (eg. "01:00 PM" - note you will get error if you try to submit "13:00 PM") 
    11.  - end_time    (required because of start_time, also in format "02:00 PM") 
    12.  - notes       (the actual work notes: eg. "Twiddled thumbs and spun on chair") 
  • Input Parameter does not match the pattern specified (6832):
    Can happen when you are on the EU datacenter and you are trying to use European date format or time format to push to Zoho Projects.
    copyraw
    // your date format
    input.Start_Date.toString("dd-MM-yyyy");
    
    // correct to US format (even if you are using projects.zoho.eu)
    input.Start_Date.toString("MM-dd-yyyy");
    1.  // your date format 
    2.  input.Start_Date.toString("dd-MM-yyyy")
    3.   
    4.  // correct to US format (even if you are using projects.zoho.eu) 
    5.  input.Start_Date.toString("MM-dd-yyyy")
    copyraw
    // your time format
    input.Start_Time.toString("HH:mm");
    
    // correct to 12-hour with meridian (even if you are using projects.zoho.eu)
    input.Start_Time.toString("hh:mm a");
    // additional note: "13:00 PM" will return this error as well
    1.  // your time format 
    2.  input.Start_Time.toString("HH:mm")
    3.   
    4.  // correct to 12-hour with meridian (even if you are using projects.zoho.eu) 
    5.  input.Start_Time.toString("hh:mm a")
    6.  // additional note: "13:00 PM" will return this error as well 

Source(s)
Category: Zoho Projects :: Article: 281

Joes Word Cloud

Accreditation

Badge - Zoho Creator Certified Developer Associate
Badge - Zoho Deluge Certified Developer
Badge - Certified Zoho CRM Developer

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Paypal:
Donate to Joel Lipman via PayPal

Bitcoin:
Donate to Joel Lipman with Bitcoin bc1qf6elrdxc968h0k673l2djc9wrpazhqtxw8qqp4

Ethereum:
Donate to Joel Lipman with Ethereum 0xb038962F3809b425D661EF5D22294Cf45E02FebF

Credit where Credit is Due:


Feel free to copy, redistribute and share this information. All that we ask is that you attribute credit and possibly even a link back to this website as it really helps in our search engine rankings.

Disclaimer: Please note that the information provided on this website is intended for informational purposes only and does not represent a warranty. The opinions expressed are those of the author only. We recommend testing any solutions in a development environment before implementing them in production. The articles are based on our good faith efforts and were current at the time of writing, reflecting our practical experience in a commercial setting.

Thank you for visiting and, as always, we hope this website was of some use to you!

Kind Regards,

Joel Lipman
www.joellipman.com