यह पृष्ठ AI टूल्स का उपयोग करके अनुवादित किया गया है और इसमें त्रुटियाँ हो सकती हैं। सबसे सटीक और नवीनतम विवरण के लिए, कृपया
मूल अंग्रेजी संस्करण देखें।
Zoho Projects में CodeX Scripts उन्नत सशर्त तर्क स्क्रिप्ट हैं जो विशिष्ट नियमों और सत्यापन को लागू करने में मदद करते हैं। उपयोगकर्ता नियंत्रित कर सकते हैं कि Task कैसे और कब बनाए जा सकते हैं, संपादित किए जा सकते हैं, या स्थिति बदली जा सकती है। यह बेहतर अनुपालन और प्रक्रिया संरेखण सुनिश्चित करता है।
CodeX Scripts को CN, JP और AE को छोड़कर सभी डेटा सेंटर में समर्थन किया जाता है।
उपयोग के मामले:
एक स्तर से अधिक Subtask निर्माण को प्रतिबंधित करें
एक Subtask के तहत दूसरे Subtask को बनाने से प्रतिबंधित करता है, एक सरल और प्रबंधनीय Task पदानुक्रम को बनाए रखने के लिए, केवल एक स्तर के Subtask की अनुमति देता है।
- function main() {
- if(current.record.parent_task !== current.record.root_task) {
- throw new ScriptError('Disable subtasks creation with more than 1 level');
- }
- }
On-Hold स्थिति वाले प्रोजेक्ट में Task निर्माण को अक्षम करें
यदि संबंधित प्रोजेक्ट को On Hold के रूप में चिह्नित किया जाता है तो Task निर्माण को प्रतिबंधित करता है।
- function main() {
- const projectId = current.record.projectId;
- const moduleItr = client.getModules();
- let module
- console.log('started');
- for (let mod of moduleItr) {
- console.log(`${mod}`);
- if (mod.name === 'Projects') {
- module = mod;
- }
- }
- if (!module) {
- return;
- }
- let projectDtl = client.getRecordById(module.id, projectId);
- let statusDtl = client.getStatusDetails(module.id, projectDtl.layoutId, projectDtl.status.id);
- console.log(statusDtl)
- if (statusDtl.name === 'zp.projstatus.onhold') {
- throw new ScriptError('Task Creation disabled for On Hold Projects');
- }
- }
स्थिति अपडेट के बाद मैनुअल दिनांक परिवर्तन को प्रतिबंधित करें
यदि स्थिति लेआउट की डिफ़ॉल्ट नहीं है तो प्रारंभ तारीख, समाप्ति तारीख, या अवधि के संपादन को प्रतिबंधित करता है।
- function main() {
-
- //base condition #1
- if (!current.affectedFields.start_date
- && !current.affectedFields.end_date
- && !current.affectedFields.duration_value
- && !current.affectedFields.duration_unit) {
- return;
- }
-
- const statusDtl = client.getStatusDetails(current.module.id, current.record.layoutId, current.record.status);
- console.log(`${statusDtl}`);
-
- if (!statusDtl.isLayoutDefault) {
- throw new ScriptError('Start Date and End date change are only allowed in default status');
- }
- }
-
यदि खुले Subtask मौजूद हैं तो Task समापन को प्रतिबंधित करें
यदि कोई भी खुला Subtask मौजूद है तो मूल Task की स्थिति को Closed में बदलने से प्रतिबंधित करता है। यह सुनिश्चित करता है कि मूल Task को पूर्ण के रूप में चिह्नित नहीं किया जा सकता जब तक कि इसके सभी Subtask बंद न हों।
-
- function main() {
-
- console.log(current.affectedFields.toString());
-
- //base condition handling
- if (!current.affectedFields?.status) {
- return;
- }
-
- const url = `https://projects.zoho.com/restapi/portal/${current.org.zohoOrgId}/projects/${current.record.projectId}/tasks/${current.record.id}/subtasks/`;
- let hasMore = true;
- const range = 200;
- let index = 1;
- console.log(url);
-
- while (hasMore) {
- let request = new HttpRequest();
- request.url(url);
- request.connection('zprojects');
- request.params({ index, range });
-
- const response = request.execute();
-
- console.log(response.asText());
- /**
- * @type {[]}
- */
- const tasks = response.asJson()?.statusMessage?.responseText?.tasks;
-
- //वर्तमान Task के लिए कोई Subtasks मौजूद नहीं हैं
- if (!tasks || tasks.length == 0) {
- console.log('वर्तमान Task के लिए कोई Subtasks मौजूद नहीं हैं');
- return;
- }
-
- hasMore = tasks.length == range;
- index += range;
-
- console.log(tasks);
- console.log(tasks.length);
-
- for (let task of tasks) {
- console.log(task.completed);
- if (!task.completed) {
- throw new ScriptError('Task को बंद नहीं किया जा सकता क्योंकि इसमें खुले Subtask(s) हैं');
- }
- }
- }
-
-
- }
यदि पूर्ववर्ती खुले हैं तो स्थिति परिवर्तन को प्रतिबंधित करें
यदि कोई भी पूर्ववर्ती Task अधूरा है तो स्थिति अपडेट को प्रतिबंधित करता है ताकि निर्भरता तर्क सुनिश्चित हो सके और उत्तरवर्ती Task अपने पूर्ववर्तियों के बंद होने के बाद ही आगे बढ़ सके।
- function main() {
- console.log(current.affectedFields.toString());
-
- //आधार स्थिति प्रबंधन
- if(!current.affectedFields?.status) {
- return;
- }
- const url = `https://projects.zoho.com/restapi/portal/${current.org.zohoOrgId}/projects/${current.record.projectId}/tasks/${current.record.id}/`;
- console.log(url);
-
- let request = new HttpRequest();
- request.url(url);
- request.connection('zprojects');
- const response = request.execute();
- const taskDependencyDtl = response.asJson()?.statusMessage?.responseText?.tasks[0]?.dependency;
- //पिछले Task में कोई निर्भरता मौजूद नहीं है
- if(!taskDependencyDtl || !taskDependencyDtl?.predecessor) {
- return;
- }
- console.log(taskDependencyDtl);
- for(let predecessorId of taskDependencyDtl.predecessor) {
- console.log(predecessorId);
- if(!taskDependencyDtl.dependencyDetails[predecessorId]?.IS_COMPLETED) {
- throw new ScriptError('खुले पूर्ववर्ती Tasks मौजूद हैं, आगे बढ़ने के लिए उन्हें बंद करें');
- }
- }
- }
Subtask निर्माण को प्रतिबंधित करें
Subtask निर्माण को प्रतिबंधित करता है ताकि सपाट Task संरचना बनी रहे।
- function main() {
- let task = current.record;
- let startDate = task.start_date;
- if(task.parent_task || task.root_task) {
- Logger.info("Subtask निर्माण अक्षम है");
- throw new ScriptError("Subtask निर्माण अक्षम है");
- }
- }
-
शर्तों के आधार पर Task अवधि और स्थिति को अपडेट करें
किसी विशिष्ट कस्टम फ़ील्ड और वर्तमान स्थिति के आधार पर Task अवधि और स्थिति को अपडेट करें।
उदाहरण के लिए, यह स्क्रिप्ट जब विशिष्ट शर्तें पूरी होती हैं तो Task की अवधि और उसकी स्थिति को अपडेट करती है:
- यदि Task की वर्तमान स्थिति "On Hold" है, तो यह स्थिति को स्वचालित रूप से एक विशिष्ट ID में परिवर्तित करता है (उदाहरण के लिए, "In Progress")।
- यदि किसी बहु-चयन कस्टम फ़ील्ड में कोई विशिष्ट मान चुना गया है, तो यह अवधि को 30 दिनों में सेट करता है।
- यह Task के बिलिंग प्रकार और प्रभावित फ़ील्ड की भी जांच करता है और लॉग करता है।
- function main() {
- let task = current.record;
- const statusDetails = client.getStatusDetails(task.moduleId, task.layoutId, task.status);
- if(statusDetails.name === 'On Hold') {
- task.status = '5000000000362';
- client.save(task);
- }
- console.log(JSON.stringify(statusDetails));
- if(task.weightage.includes("Medium") { //बहु-चयन फ़ील्ड में कुछ विकल्प हैं या नहीं यह जांचें
- console.log('setting status to In Progress');
- task.duration_unit = TaskDurationUnit.DAYS;
- task.duration_value = 30;
- }
- }
आर्काइव किए गए प्रोजेक्ट्स के लिए संपादन प्रतिबंधित करें
यदि किसी Task का प्रोजेक्ट आर्काइव किया गया है, तो उस Task के किसी भी अपडेट को प्रतिबंधित करता है ताकि ऐसे प्रोजेक्ट्स के तहत कोई Task संपादन न किया जा सके।
- function main() {
- let task = current.record;
- let projectId = task.projectId;
- const moduleItr = client.getModules(0, 10);
- let moduleId;
- console.log(JSON.stringify(current.affectedFields));
- while(moduleItr.hasNext()) {
- let moduleObj = moduleItr.next();
- if(moduleObj.name == 'Projects') {
- moduleId = moduleObj.id;
- }
- }
- let project = client.getRecordById(moduleId, projectId);
- if(project.project_type == 'archived') {
- throw new ScriptError("Edits are disabled for archived projects");
- }
- }
पिछली प्रारंभ तारीखों को प्रतिबंधित करें
यदि चयनित प्रारंभ तारीख अतीत की है तो त्रुटि फेंकता है ताकि सटीक शेड्यूल बनाए रखा जा सके।
- function main() {
- let task = current.record;
- let date = Date.now();
- for(let key of Object.keys(current)) {
- console.log(key);
- }
- const startDate = new Date(task.start_date)
- if(date > startDate) {
- console.log('Start date is in past date');
- throw new ScriptError('Start date cannot be updated with past dates');
- }
- }
शर्त के आधार पर Task संपादन प्रतिबंधित करें
यदि चेकबॉक्स फ़ील्ड सक्षम है तो Task को किसी भी अपडेट से प्रतिबंधित करता है, सिवाय चेकबॉक्स को स्वयं बदलते समय अनावश्यक परिवर्तनों को रोकने के लिए।
- function main() {
-
- const affectedFields = current.affectedFields;
- const task = current.record;
-
- if(affectedFields && typeof affectedFields['checkbox_cf'] != 'undefined') {
- return; //यदि चेकबॉक्स को स्वयं अपडेट किया जाता है तो कुछ न करें।
- }
-
- //चेकबॉक्स प्रकार फ़ील्ड के लिए बूलियन मान
- if(task.checkbox_cf) {
- throw new ScriptError('The check box is enabled, task is locked. ')
- }
- }
-
कस्टम स्थिति के साथ Task तारीखों को अपडेट करना प्रतिबंधित करें
जब Task किसी कस्टम स्थिति में हो तो Task की प्रारंभ और समाप्ति तारीख को अपडेट करने पर प्रतिबंध लगाएं।
- function main() {
- try {
- if (!current.affectedFields.start_date
- && !current.affectedFields.end_date
- && !current.affectedFields.duration_value
- && !current.affectedFields.duration_unit) {
- return;
- }
- const statusDtl = client.getStatusDetails(current.record.moduleId, current.record.layoutId, current.record.status.id);
- console.log(`${statusDtl}`);
- if (!statusDtl.isLayoutDefault) {
- throw new ScriptError('Start Date and End date change are only allowed in default status');
- }
- } catch (err) {
- throw new ScriptError(err);
- }
- }
क्या आपके पास कोई विचार है कि आप अपने प्रोजेक्ट सेटअप में CodeX को कैसे काम करना चाहते हैं? नीचे दिए गए टिप्पणियों में अपना उपयोग केस साझा करें।
अधिक पढ़ें