CodeX Scripts for Projects | Help | Zoho Projects

CodeX Scripts for Projects

CodeX Scripts in Zoho Projects are advanced conditional logic scripts that help enforce specific rules and validations. Users can control how and when a project can be created, edited, or transitioned. This ensures better compliance and process alignment.

Info
CodeX Scripts are currently available as a limited release. To enable this feature for your portal, please contact support@zohoprojects.com

Use Cases: 

Create a New Project

Creates a new project with populated project records with owner, dates, budget, and custom fields filled in.
Code:
  1. function main() {
  2.   try {
  3.     const layoutId = current.record.layoutId;
  4.     const moduleId = current.record.moduleId;
  5.     const layout = client.getLayoutById(layoutId, moduleId);

  6.     const newProject = new Record(layout);
  7.     newProject.name = "Explore Zoho ";

  8.     const projectOwnerId = variables.projectowner.value;

  9.     const user1 = variables.user1.value; // ZPUID of user1 is stored in variables
  10.     const user2 = variables.user2.value; // ZPUID of user2 is stored in variables

  11.     const addedProject = client.save(newProject);
  12.     addedProject.name = "Explore Zoho Projects";
  13.     addedProject.description =
  14.       "Explore Zoho Projects features and functionalities";
  15.     addedProject.owner = projectOwnerId;
  16.     addedProject.status = "242942000000027095"; // status Id based on layout. Here, 242942000000040005 corresponds to 'In Progress' status
  17.     addedProject.start_date = "2025-12-08";
  18.     addedProject.end_date = "2025-12-25";
  19.     addedProject.project_group = "242942000000025001"; // project group Id
  20.     addedProject.completed_time = "2025-12-31T00:00:00+05:30"; // completed time should be proivded in ISO date and time formate
  21.     addedProject.currency = "INR"; // Currency code
  22.     addedProject.budget_type = "1"; // Budget Type
  23.     addedProject.hourly_budget = "5.000";
  24.     addedProject.hourly_budget_threshold = "3.000";
  25.     addedProject.cost_budget = "5600";
  26.     addedProject.cost_budget_threshold = "5000";
  27.     addedProject.revenue_budget = "4000";
  28.     addedProject.billing_method = "1"; // Billing Method Ref: BillingMethod enum in IDE.
  29.     addedProject.rate_per_hour = "800";
  30.     addedProject.cost_per_hour = "600";

  31.     addedProject.single_line_text = "Sample Single Line Text";
  32.     addedProject.pick_list = "Option 1"; // Value based on picklist options in layout
  33.     addedProject.multi_line_text =
  34.       "Lorem sunt Duis dolor laborum \n eu magna incididunt ipsum qui sit pariatur \n aute officia nisi irure nostrud sit commodo esse";
  35.     addedProject.multi_select_field = ["Option 1", "Option 2", "Option 3"]; // Values based on multi select options in layout
  36.     addedProject.user_pick_list_all_users = user1;
  37.     addedProject.user_pick_list_select_roles = "242942000000082031"; // Role Id based on org roles
  38.     addedProject.user_pick_list_selected_users = user2;
  39.     addedProject.multi_user_picklist_all_users = [user1, user2];
  40.     addedProject.multi_user_picklist_selected_roles = [
  41.       "242942000000082031",
  42.       "242942000000082001",
  43.     ];
  44.     addedProject.multi_user_picklist_selected_users = [user1, user2];
  45.     addedProject.date_field = "2025-12-08"; // Date field value in ISO Date format
  46.     addedProject.checkbox_field = "true";
  47.     addedProject.currency_field = "4300";
  48.     addedProject.percentage_field = "25"; // Percentage value without % symbol
  49.     addedProject.decimal_field = "130.24";
  50.     addedProject.number_field = "430020";
  51.     addedProject.email_field = "vishal@yahoo.com";
  52.     addedProject.phone_field = "1234567890";
  53.     addedProject.url_field = "https://zlyker.com/";
  54.     client.save(addedProject);
  55.   } catch (err) {
  56.     console.log(err);
  57.     throw new ScriptError(err);
  58.   }
  59. }

Create a New Entity

Creates a blank record in any module with just a name field set to use it for debugging or validation.
Code:
  1. function main() {

  2.     try {

  3.         let layout = client.getLayoutById(current.record.layoutId, current.record.moduleId);

  4.         let record = new Record(layout);

  5.         record.name = "created project from script"

  6.         client.save(record);

  7.     } catch (err) {

  8.         throw new ScriptError(err);

  9.     }

  10. }
  11.  

Restrict Task Edits in Archived Projects

Restricts task edits when the associated project is archived.
Code:
  1. function main() {
  2.     let task = current.record;
  3.  
  4.     let projectId = task.projectId;
  5.     const moduleItr = client.getModules(0, 10);
  6.     //projects module id: 5000000000380
  7.     let moduleId;
  8.     console.log(JSON.stringify(current.affectedFields));
  9.     while(moduleItr.hasNext()) {
  10.         let moduleObj = moduleItr.next();
  11.         if(moduleObj.name == 'Projects') {
  12.             moduleId = moduleObj.id;
  13.         }
  14.         
  15.     }
  16.     let project = client.getRecordById(moduleId, projectId);
  17.  
  18.     if(project._status == 'archived') {
  19.         throw new ScriptError("Edits are disabled for archived projects");
  20.     }
  21.  
  22.  
  23. }
  24.  
Got an idea for how you would like CodeX to work in your project setup? Drop your use case in the comments below!

More Reads

      Create. Review. Publish.

      Write, edit, collaborate on, and publish documents to different content management platforms.

      Get Started Now


        Access your files securely from anywhere

          Zoho CRM Training Programs

          Learn how to use the best tools for sales force automation and better customer engagement from Zoho's implementation specialists.

          Zoho CRM Training
            Redefine the way you work
            with Zoho Workplace

              Zoho DataPrep Personalized Demo

              If you'd like a personalized walk-through of our data preparation tool, please request a demo and we'll be happy to show you how to get the best out of Zoho DataPrep.

              Zoho CRM Training

                Create, share, and deliver

                beautiful slides from anywhere.

                Get Started Now


                  Zoho Sign now offers specialized one-on-one training for both administrators and developers.

                  BOOK A SESSION







                              Quick LinksWorkflow AutomationData Collection
                              Web FormsEnterpriseOnline Data Collection Tool
                              Embeddable FormsBankingBegin Data Collection
                              Interactive FormsWorkplaceData Collection App
                              CRM FormsCustomer ServiceAccessible Forms
                              Digital FormsMarketingForms for Small Business
                              HTML FormsEducationForms for Enterprise
                              Contact FormsE-commerceForms for any business
                              Lead Generation FormsHealthcareForms for Startups
                              Wordpress FormsCustomer onboardingForms for Small Business
                              No Code FormsConstructionRSVP tool for holidays
                              Free FormsTravelFeatures for Order Forms
                              Prefill FormsNon-Profit

                              Intake FormsLegal
                              Mobile App
                              Form DesignerHR
                              Mobile Forms
                              Card FormsFoodOffline Forms
                              Assign FormsPhotographyMobile Forms Features
                              Translate FormsReal EstateKiosk in Mobile Forms
                              Electronic Forms
                              Drag & drop form builder

                              Notification Emails for FormsAlternativesSecurity & Compliance
                              Holiday FormsGoogle Forms alternative GDPR
                              Form to PDFJotform alternativeHIPAA Forms
                              Email FormsFormstack alternativeEncrypted Forms

                              Wufoo alternativeSecure Forms

                              TypeformWCAG


                                          Create. Review. Publish.

                                          Write, edit, collaborate on, and publish documents to different content management platforms.

                                          Get Started Now




                                                            You are currently viewing the help pages of Qntrl’s earlier version. Click here to view our latest version—Qntrl 3.0's help articles.




                                                                Manage your brands on social media


                                                                  • Desk Community Learning Series


                                                                  • Digest


                                                                  • Functions


                                                                  • Meetups


                                                                  • Kbase


                                                                  • Resources


                                                                  • Glossary


                                                                  • Desk Marketplace


                                                                  • MVP Corner


                                                                  • Word of the Day


                                                                  • Ask the Experts


                                                                    Zoho Sheet Resources

                                                                     

                                                                        Zoho Forms Resources


                                                                          Secure your business
                                                                          communication with Zoho Mail


                                                                          Mail on the move with
                                                                          Zoho Mail mobile application

                                                                            Stay on top of your schedule
                                                                            at all times


                                                                            Carry your calendar with you
                                                                            Anytime, anywhere




                                                                                  Zoho Sign Resources

                                                                                    Sign, Paperless!

                                                                                    Sign and send business documents on the go!

                                                                                    Get Started Now




                                                                                            Zoho TeamInbox Resources





                                                                                                      Zoho DataPrep Demo

                                                                                                      Get a personalized demo or POC

                                                                                                      REGISTER NOW


                                                                                                        Design. Discuss. Deliver.

                                                                                                        Create visually engaging stories with Zoho Show.

                                                                                                        Get Started Now








                                                                                                                            • Related Articles

                                                                                                                            • Working with CodeX Scripts

                                                                                                                              CodeX Scripts allows users to define custom logic that runs automatically based on events in the modules such as when a project or task is created, updated, or deleted. These scripts help enforce validations, restrict actions, or apply conditions ...
                                                                                                                            • CodeX Scripts - Intro

                                                                                                                              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 ...
                                                                                                                            • CodeX Scripts for Tasks

                                                                                                                              CodeX Scripts in Zoho Projects are advanced conditional logic scripts that help enforce specific rules and validations. Users can control how and when tasks can be created, edited, or transitioned. This ensures better compliance and process ...
                                                                                                                            • JavaScript SDK for CodeX Scripts

                                                                                                                              Codex Scripts in Zoho Projects allow users to customize how the projects and tasks operate. Using these scripts, users can automate validations and actions, integrate external systems, and retrieve or update the data. CodeX Scripts are currently ...
                                                                                                                            • CodeX Credits

                                                                                                                              CodeX credits allows admins to monitor and analyze the number of CodeX script executions in Zoho Projects. Each time a script is executed, it uses one credit. Credits are allocated based on the organizations' subscription plan and will reset every ...
                                                                                                                              Wherever you are is as good as
                                                                                                                              your workplace

                                                                                                                                Resources

                                                                                                                                Videos

                                                                                                                                Watch comprehensive videos on features and other important topics that will help you master Zoho CRM.



                                                                                                                                eBooks

                                                                                                                                Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho CRM.



                                                                                                                                Webinars

                                                                                                                                Sign up for our webinars and learn the Zoho CRM basics, from customization to sales force automation and more.



                                                                                                                                CRM Tips

                                                                                                                                Make the most of Zoho CRM with these useful tips.



                                                                                                                                  Zoho Show Resources