CodeX Scripts in Zoho Projects enforce your own rules and validations, and they now cover custom modules. A script can decide when a custom module record may be created, updated, or deleted. This article explains the six example rules Zoho provides and the event each one runs on, so you can adapt them to your own modules.
Availability: CodeX Scripts are supported in all Zoho data centres except CN, JP, and AE.
About the examples: Zoho's samples use a custom module called ReviewModule to show how scripts enforce business rules. You can swap in any custom module that suits your workflow, such as Change Requests or Asset Requests. Update the module name, field names, and validation logic to match your requirements, and reuse the same scripts.
The six example rules
| Rule |
What it does |
Event |
| Validate start and end date order | Checks that the End Date is not earlier than the Start Date when a record is created. A record with an invalid date sequence is rejected. | Before Create |
| Restrict past dates on update | Stops users changing the Start Date, End Date, or Review Completion Date to a date in the past. | Before Update |
| Validate start and end date order on update | Checks that the End Date is not earlier than the Start Date when a record is updated. It also requires a Start Date whenever an End Date is provided. | Before Update |
| Restrict open record limit per user | Stops a user creating a new record when they already have more than 10 open records in the module. | Before Create |
| Restrict past dates on creation | Stops users creating a record with a Start Date, End Date, or Review Completion Date in the past. | Before Create |
| Restrict editing to related users and administrators | Allows updates only from users associated with the record, such as its creator or assigned users, or from users with the Administrator role. Everyone else is blocked. | Before Update |
How the scripts behave
- Each script runs on an event, either before a record is created or before it is updated, and rejects the action with a clear message if the rule is broken.
- If something unexpected goes wrong inside a script, the user sees a generic message asking them to contact the portal administrator, rather than the technical error.
- The open record limit and the editing restriction look up extra information through the Zoho Projects API, so they rely on a connection being set up. The date rules need no outside lookups.
- The date examples compare dates at day level, so the time of day does not affect the result.
Adapting a rule to your own module
- Pick the example closest to the rule you need, and note which event it uses.
- Replace the example field names with the field names in your own module.
- Change the limits and messages, such as the open record limit of 10, to suit your process.
- Test in a sandbox project before switching it on in a live portal.
Need help? As a Zoho Partner serving the UK and Ireland, we can design custom modules in Zoho Projects and write and test the CodeX Scripts that enforce your business rules.
Book a discovery call with 1 Cloud Consultants.