For Zoho Services only:


I'm actually part of a bigger team at Ascent Business Solutions where we have support technicians and project consultants. Support is for smaller technical fixes but this can include developments, reports or integrations; depending on the size of the task. Projects are for more time-consuming developments such as revamps of the Zoho Suite of apps or on-site training. The advantage of a team is that if I am out-of-office for a day or so, there is always someone at Ascent Business Solutions who can deal with any queries/issues you may have.

Our support rates can be found and purchased at http://ascentbusiness.co.uk/zoho-support-2. A support bundle doesn't have an expiry date. So whether we can do what you want within the bundle and a year later need further support, if there are minutes left on the bundle then there is no additional charge.

Our project rates for bigger developments can be found at http://ascentbusiness.co.uk/crm-solutions/zoho-crm-packages-prices and will involve a dedicated project consultant along with developers who will hold your hand through the development process.

If you want help building a solution for one of the Zoho Apps in the Zoho Suite, contact us on 0121 293 8140 (UK) or by email at info@ascentbusiness.co.uk. You can also visit our website at http://ascentbusiness.co.uk.

I regularly build and specialize in 2-way API integrations for Xero, Shopify and eBay.

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: The information on this website is provided without warranty and any content is merely the opinion of the author. Please try to test in development environments prior to adapting them to your production environments. The articles are written in good faith and, at the time of print, are working examples used 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 - Valid till 8 May 2022 3QnhmaBX7LQSRsC9hh6Je9rGQKEGNQNfPb
© 2021 Joel Lipman .com. All Rights Reserved.