In a project, when users work on multiple tasks simultaneously, they track time in different ways, either by starting a timer or by adding a time log. Sometimes users may forget to add time, which can lead to discrepancies in the timesheet.
When
timesheets have incorrect time logs, the billable amount might not reflect the true
budget and can lead to inaccurate billing. CodeX Script addresses this by displaying a custom message, forcing the user to add a time log before they update the status of a task.
Let's consider a law firm where associate attorneys move between Client Consultations and Case Reviews. During a consultation session, an associate might start a timer and update the task status to Under Review without logging the time. With this Codex Script, a message is triggered while attempting a status change to Under Review, keeping the task in the existing status until the time is logged.
To configure this in your Zoho Projects portal,
1. Navigate to the upper-right corner of the page and click
→ Developer Space → Connections. 2. Click
Create Connection, choose
Zoho Projects as the service, and add the following scope:
- ZohoProjects.timesheets.READ
4. Click Create CodeX Script in the upper-right corner.
5. Enter the CodeX Script Name.
6. Select the required Module, Layout and Event as shown below.
7. Add the following Codex script in the script editor.
- // scopes: ZohoProjects.timesheets.READ
- function main() {
- if (current.affectedFields.status) {
- if (current.affectedFields.status.newValue.name == "Under Review") {
- const url = `https://projects.zoho.eu/api/v3/portal/${current.org.zohoOrgId}/projects/${current.record.projectId}/timelogs`
- const request = new HttpRequest();
- request.url(url);
- request.method('get');
- request.params({ "view_type": "projectspan", "module": { "id": current.record.id, "type": "task" }, "page": "1", "per_page": "200" });
- request.connection('connectionprojects');
- const response = request.execute();
- if (response.asJson().statusMessage.responseText.time_logs.length == 0) {
- throw new ScriptError("Add timelog and complete the task");
- }
- }
- }
- }
Line 4: Replace "Under Review" with the task status name configured in your portal.
Line 5: Replace the domain like AU, EU, CN, IN etc.in the URL to match your data centre
Line 10: Replace "connectionprojects" with your Zoho Projects connection name.
Line 12: Replace the Script Error message with the prompt text you want displayed to the user.
8. Click Save to execute the script.
Once this is setup, time logging does not have to be yet another task to be remembered, keeping time logs complete and billing records accurate.
Do give this a try and let us know how it works for you in the comments below, or write to us at
support@zohoprojects.com for any questions.