CodeX Scripts let you define custom logic that runs automatically when users interact with tasks or projects. It allows users to control how the module behaves based on certain conditions. Users can write scripts using
JavaScript SDKs to trigger actions before or after a record is created or updated. Users with
CodeX Scripts permission can configure and manage CodeX Scripts.
CodeX Scripts are supported in all data centers except CN JP and AE.
Benefits
- Validate conditions and prompt custom restriction messages within the project and task module.
- Connect with external apps using HTTP requests.
- Automatically update tasks or project details based on conditions.
- Retrieve and update other project records in your portal.
How CodeX Scripts differ from Custom Functions?
Zoho Projects provides two ways to add custom logic, CodeX Scripts and Custom Functions. While both allow users to extend system behavior, they are designed for different purposes.
CodeX Scripts
- Written in JavaScript using the CodeX SDK.
- Runs automatically based on record events such as before or after a task/project is created, updated, or deleted.
- Used to validate conditions, restrict actions, or control how the module behaves.
- Suitable for enforcing process rules or validations at organization level.
Custom Functions
- Written in Deluge. Learn more.
- Used to automate actions, such as updating records, sending notifications, or integrating with external services.
- They can also be associated with workflow rules or task blueprints to trigger actions based on the criteria.
For example, in a project, if you want to restrict your project members from creating subtasks for a closed task or an active task, you can use the CodeX Scripts to write in the code using the objects and the methods, to execute on a trigger such as "Before Create" and save.
Script:
This will prompt your project members with an alert that the subtasks cannot be created for this task when the user tries to create a subtask.
Execution:
- function main() {
- let task = current.record;
- /**
- *
- * @type Number
- */
- let startDate = task.start_date;
- Logger.info('Parent ID: ' + task.parent_task);
- Logger.info('Root Task ID: ' + task.root_task);
-
- // console.log(JSON.stringify(variables.blockSubTasks));
- if(task.parent_task || task.root_task) {
- Logger.info("Subtask creation is disabled");
- throw new ScriptError("You cannot create a subtask");
- }
- }
Find other CodeX scripts to customize how
task and
project module should operate.