For Zoho Services only:


I'm actually part of something bigger at Ascent Business Solutions recognized as the top Zoho Premium Solutions Partner in the United Kingdom.

Ascent Business Solutions offer support for smaller technical fixes and projects for larger developments, such as migrating to a ZohoCRM.  A team rather than a one-man-band is always available to ensure seamless progress and address any concerns. You'll find our competitive support rates with flexible, no-expiration bundles at http://ascentbusiness.co.uk/zoho-support-2.  For larger projects, check our bespoke pricing structure and receive dedicated support from our hands-on project consultants and developers at http://ascentbusiness.co.uk/crm-solutions/zoho-crm-packages-prices.

The team I manage specializes in coding API integrations between Zoho and third-party finance/commerce suites such as Xero, Shopify, WooCommerce, and eBay; to name but a few.  Our passion lies in creating innovative solutions where others have fallen short as well as working with new businesses, new sectors, and new ideas.  Our success is measured by the growth and ROI we deliver for clients, such as transforming a garden shed hobby into a 250k monthly turnover operation or generating a +60% return in just three days after launch through online payments and a streamlined e-commerce solution, replacing a paper-based system.

If you're looking for a partner who can help you drive growth and success, we'd love to work with you.  You can reach out to us on 0121 392 8140 (UK) or info@ascentbusiness.co.uk.  You can also visit our website at http://ascentbusiness.co.uk.

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 :: Article: 743

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

Related Articles

Joes Revolver Map

Accreditation

Badge - Certified Zoho Creator Associate
Badge - Certified Zoho Creator Associate

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
© 2024 Joel Lipman .com. All Rights Reserved.