JS SDK

JS SDK

先决条件


在调用以下 SDK 方法之前,请在代码中包含 JS 代码 https://js.zohocdn.com/projects/js/client_sdk.min.js。

请在代码中包含 CSS 代码 https://css.zohocdn.com/projects/styles/zps-extn/client_sdk.css,以便使用 Zoho Projects 样式。

 

init

初始化扩展程序。

zohoprojects.init().then(function(){});      

 

必须在开始时调用此方法,因为其他 SDK 方法只有在调用此方法后才能生效。在 init 加载期间,如果您想使用其他函数,可以在 init 函数中调用。


zohoprojects.init().then(function () {
      zohoprojects.get("portal.name").then(function (response)
      });

 

metadata

获取扩展程序的付款和配置详细信息。


},
                     "status": "success"
                      }
                     }
                    */
           });                              

 

context

获取当前位置的模块名称和实体 ID。模块名称为“tasks”或“issues”,实体 ID 为相应任务或问题的 ID。


zohoprojects.context().then(function(response)
{
/* output
{
     "module_name": "tasks",
      "entity_id": "27092000000031079"
  }
     */
      });                                         


get

get 当前位置的实例、当前用户、门户、项目、任务和问题的详细信息。

zohoprojects.get("task.id

").then(function(response)

{
/* output
{
"data": 27092000000031080,
"status": "success"
}
*/
});
                                


以下是 get 方法中可以使用的键的列表:

实例

  • instances

 

当前用户

  • current_user


门户

  1. portal.trial_enabled

  2. portal.settings

  3. portal.gmt_time_zone

  4. portal.project_count

  5. portal.role

  6. portal.avail_user_count

  7. portal.locale

  8. portal.project_prefix

  9. portal.available_projects

  10. portal.max_user_count

  11. portal.profile_id

  12. portal.name

  13. portal.id_string

  14. portal.bug_plural

  15. portal.plan

  16. portal.bug_plan

  17. portal.bug_singular portal.default

  18. portal.extensions

  19. portal.is_crm_partner

  20. portal.is_display_projectprefix

  21. portal.is_display_taskprefix

  22. portal.is_new_plan

  23. portal.layouts

  24. portal.link


项目

  1. project.is_strict

  2. project.role

  3. project.bug_count

  4. project.owner_id

  5. project.taskbug_prefix

  6. project.link

  7. project.description

  8. project.milestone_count

  9. project.updated_date_long

  10. project.task_count

  11. project.updated_date_format

  12. project.workspace_id

  13. project.billing_status

  14. project.key

  15. project.is_chat_enabled

  16. project.owner_name

  17. project.profile_id

  18. project.enabled_tabs

  19. project.name

  20. project.is_public

  21. project.layout_details

  22. project.status

  23. project.permissions

  24. project.IS_BUG_ENABLED

  25. project.bug_defaultview

  26. project.bug_prefix

  27. project.cascade_setting

  28. project.completed_on

  29. project.completed_on_long

  30. project.created_date

  31. project.created_date_format

  32. project.created_date_long

  33. project.custom_status_id

  34. project.id_string

  35. project.show_project_overview

  36. project.start_date

  37. project.start_date_long

  38. project.updated_date

  39. project.users

  40. project.customfields

  41. project.custom_fields

任务

  1. task.name

  2. task.completed

  3. task.created_by

  4. task.priority

  5. task.percent_complete

  6. task.start_date

  7. task.end_date

  8. task.dependency

  9. task.duration

  10. task.details

  11. task.link

  12. task.created_person

  13. task.created_time

  14. task.created_time_format

  15. task.created_time_long

  16. task.custom_fields

  17. task.depth (applicable for subtasks only)

  18. task.duration_type

  19. task.id_string

  20. task.is_comment_added

  21. task.is_forum_associated

  22. task.is_recurrence_set

  23. task.is_reminder_set

  24. task.isparenttask.key

  25. task.last_updated_time

  26. task.last_updated_time_format

  27. task.last_updated_time_long

  28. task.milestone_id

  29. task.order_sequence

  30. task.parent_task_id (applicable for subtasks only)

  31. task.parenttask_id (applicable for subtasks only)

  32. task.root_task_id (applicable for subtasks only)

  33. task.status

  34. task.task_followers

  35. task.tasklist

  36. task.worktask.work_type

  37. task.comments

  38. task.subtasks

  39. task.customfields

  40. task.attachments


问题

  1. issue.module

  2. issue.created_time_long

  3. issue.customfields

  4. issue.status

  5. issue.reproducible

  6. issue.link

  7. issue.severity

  8. issue.reported_person

  9. issue.title

  10. issue.flag

  11. issue.assignee_name

  12. issue.reporter_id

  13. issue.classification

  14. issue.created_time_format

  15. issue.closed

  16. issue.created_time

  17. issue.key

  18. issue.attachment_count

  19. issue.bug_number

  20. issue.bug_prefix

  21. issue.comment_count

  22. issue.escalation_level

  23. issue.id_string

  24. issue.reporter_email

  25. issue.reporter_non_zuser

  26. issue.updated_time

  27. issue.updated_time_format

  28. issue.updated_time_long

  29. issue.attachments

  30. issue.comments

  31. issue.views

 

里程碑

  1. milestone.closed

  2. milestone.comments_count

  3. milestone.created_time

  4. milestone.created_time_format

  5. milestone.created_time_long

  6. milestone.end_date

  7. milestone.end_date_format

  8. milestone.end_date_long

  9. milestone.flag

  10. milestone.has_comments

  11. milestone.id

  12. milestone.id_string

  13. milestone.is_workfield_removed

  14. milestone.last_updated_time

  15. milestone.last_updated_time_format

  16. milestone.last_updated_time_long

  17. milestone.link

  18. milestone.name

  19. milestone.owner_id

  20. milestone.owner_name

  21. milestone.owner_zpuid

  22. milestone.project

  23. milestone.sequence

  24. milestone.start_date

  25. milestone.start_date_format

  26. milestone.start_date_long

  27. milestone.status

  28. milestone.status_det


已选择文件

队列中待上传的文件存储在 chosen_files 中。此键仅支持附件选择器。

  • chosen_files

 

部署类型

获取当前数据中心。

zohoprojects.get("deployment_type").then(function() {
/* output
com
*/
});

 

个人资料

我们支持几个键,分别用于获取门户级别的所有个人资料和当前用户的个人资料详情。

all_profiles:获取门户中所有个人资料的信息。

current_profile:获取当前用户的个人资料详情。

主题

Zoho Projects 支持为您的门户提供主题。

  • current_theme: Fetches the current theme.


zohoprojects.get("current_theme").then(function() {
/* output
{mode: "default", zpPrimary: "255, 100, 0", zpPrimaryHover: "255, 247, 243"}
*/
});
                                                

 


蓝图中

  • blueprint_during: fetches the value set for the During action


zohoprojects.get("blueprint_during").then(function(res) {
/* output
[ {field_id: "UDF_CHAR1", is_visible: true, is_pii: false, is_encrypted: false}
{field_id: "UDF_CHAR2", is_visible: true, is_pii: false, is_encrypted: false}]
*/
});


迁移

获取当前转换的详细信息。

  • 迁移:获取当前转换的 ID 和名称。

  • 蓝图:获取蓝图 ID 和名称。


设置

更新当前位置的特定任务或问题的属性。

可以在任务的设置方法中使用以下键:

 



var nameObj={name:"Create a new checklist"};
zohoprojects.set("task",nameObj).then(function(response)
  {
    /* output
   {
   "data": {



任务

  1. person_responsible

  2. owner_work

  3. work_type

  4. name

  5. start_date

  6. end_date

  7. start_time

  8. end_time

  9. percent_complete

  10. duration

  11. duration_type

  12. reminder

  13. priority

  14. description

  15. custom_fields (This key can be used only to create a custom field.)

  16. clear_date

  17. index

  18. range

  19. json_string

  20. subtasks (This key can be used only to create a subtask. )


可以在问题的设置方法中使用以下键:


问题

  1. title

  2. description

  3. assignee

  4. flag

  5. classification_id

  6. milestone_id

  7. due_date

  8. module_id

  9. severity_id

  10. reproducible_id

  11. status_id

  12. resolution

  13. affectedmile_id

可以在 set 方法中使用以下键来更新项目:

项目

  1. name

  2. description

  3. status

  4. start_date

  5. end_date

  6. strict_project

  7. public

  8. group_id

  9. completed_on

  10. UDF_CHAR([1-9]|[1-2][0-9]|30). Example: UDF_CHAR1

  11. UDF_TEXT([1-9]|1[0-5])

  12. UDF_LONG([1-9]|1[0-5])

  13. UDF_USER[1-5]

  14. UDF_DOUBLE([1-9]|[1-2][0-9]|3[0-5])

  15. UDF_DATE[1-5]

  16. UDF_ENCRYPT([1-9]|10)

  17. owner

  18. billing_method

  19. bill_status

  20. show_project_overview

  21. custom_status


可以在设置方法中使用以下键来更新里程碑:

里程碑

  1. name

  2. start_date

  3. end_date

  4. owner

  5. flag

  6. budget

  7. threshold

  8. revenue_budge

 

链接文件

使用 linkfiles 键将文件与您的位置关联。此键支持以下位置:任务详情选项卡、问题详情选项卡、附件选择器。它必须是一个最大长度为 10 的数组,并且以下字段为必填字段:id、name、type、permanent_url、download_url、size、created_by、created_time;图片文件的 preview_url 为必填字段。

  • linkfiles


"name": "sample-image.jpeg",
"download_url": "https://drive.google.com/a/web-mailhosting.com/uc?id=1LavBS5sauJ-AAFJZWp8Ch9Cp2ehydahk&export=download",
}]
zohoprojects.set('linkfiles', linkFiles).then(function (response) {
zohoprojects.invoke('attachment_picker.close');
});

 


蓝图中

在配置蓝图迁移的“期间”操作时设置该值。

var sample = [ {field_id: "UDF_CHAR1", is_visible: true, is_pii: false, is_encrypted: false}
{field_id: "UDF_CHAR2", is_visible: true, is_pii: false, is_encrypted: false}];
zohoprojects.set("blueprint_during", sample).then(function(res) {
  /* output
[ {field_id: "UDF_CHAR1", is_visible: true, is_pii: false, is_encrypted: false}
{field_id: "UDF_CHAR2", is_visible: true, is_pii: false, is_encrypted: false}]
*/


导出位置

将您的任务导出到云存储服务。您最多可以选择五个数据字段,显示在导出详情弹出窗口中。如果在显示数据中添加了链接参数,所选位置将以超链接形式显示,方便访问。

let paramObj = {
"custom_data": {
"path": "G/pics",
"portal_id": "89031033",
"project_id": "185977000000199005"
},

Request

使用 plugin-manifest.json 文件中定义的连接,从您的扩展程序调用第三方 URL。如果未指定连接链接名称,则根据输入提供响应。



var file = document.getElementById("inputbox").files[0];
var file_detail = {
type: "GET",
files: [{
uploaddoc : file
type : "binary" //If the file is uploaded as binary
}],
parameters: {
fields: "id,name, thumbnailLink, webViewLink, webContentLink"
}
};
var url = "https://www.googleapis.com/drive/v3/files/1-QabBt69U8myXYRDVU-1YiCo2k-JWRfu";
zohoprojects.request(url, file_detail, "google_drive").then(function (response)
/* Output
{
"result": {
"webContentLink": "https://drive.google.com/uc?id=1-QabBt69U8myXYRDVU-1YiCo2k-JWRfu&export=download",
"name": "Eiffel_Tower_01.jpg",
"webViewLink": "https://drive.google.com/file/d/1-QabBt69U8myXYRDVU-1YiCo2k-JWRfu/view?usp=drivesdk",
"id": "1-QabBt69U8myXYRDVU-1YiCo2k-JWRfu",
"thumbnailLink": "https://lh3.googleusercontent.com/nhyq9mHrGDOZfNdQUHRj_xVlOoNAP5PEYkW4X2svGXKjVt53MvMGfjhQ2PlTv4cmv5-PgbjrR-c=s220"
},
"status": "success"
}
*/});

 

 

 

Argument name

Data type

Description

URL

string

The third-party URL that has to be invoked from your extension.

object

JSONObject

Key

Data type

Value

 

 

type

string

"GET" / "POST" / "PUT" / "DELETE" / "PATCH"

 

 

parameters

JSONObject

The request params of the API.

 

 

headers

JSONObject

The headers of the API.

 

 

body

JSONObject

The body of the API.

 

 

 

files

JSONArray

The parameters for uploading a file.

Value: the actual file.

*The body will be ignored if actual file is uploaded

*If you mention the type as binary, the file will sent as binary. The body of the file will also be considered

 

 

replace_secure_config

Boolean

If the is_secure parameter in the plugin-manifest.json file is true, set the value of this param to true.

You can pass the values in the URL and object parameter in this format - {{name}} //name of the configuration

Zoho Projects will replace the configuration value
Note: The default value is false.

connection_link_name

string

The connection link name generated from the zapps website. You can get the connection link name from plugin-manifest.

 


执行函数

在 Sigma 中执行自定义函数,无需触发器。执行该函数时必须提供 Function_uuid 及其版本号。

let customData = {"name":"Create a new checklist"};
 
zohoprojects.function.execute("c8a9e660-95e2-11ef-9d3c-2d653cc724d7", "1.0", customData).then(function(response){
 
/* output

 

要检索自定义数据,请使用以下语法:

metaData = data.getJSON("parameters").getJSON("metadata").toMap();

payload = metaData.getJSON("custom_data");
    • Related Articles

    • 使用 CLI 创建扩展

      概述 Zoho Marketplace 是一个在线商店,您可以在其中上传您为 Zoho 任何产品开发的扩展程序。您也可以将我们商店中提供的扩展程序用于您的业务。本开发者指南将帮助您构建扩展程序并将其部署到我们的 Marketplace。 开始前需要记住的事项 清单文件 每个扩展程序都必须有一个自己的 plugin-manifest.json 文件来定义其行为。定义此文件后,您可以使用 HTML、JavaScript 和 CSS ...
    • 门户级别工时日志报表

      组织级别的时间日志报表显示所有项目的时间日志。报表显示可计费小时数、不可计费小时数以及项目预算(如已启用)。报表可按项目或客户查看。 点击左侧导航面板中的“报表”。 点击下拉面板。 选择“时间日志报表”。 使用日期选择器选择报表的时间范围。 点击过滤器图标 () 并设置过滤器以生成更准确的报表。 点击 将报表导出为 PDF 或 XLS 文件。 客户报表 前往“报表”>“工时日志报表”。 点击“客户报表”。
    • WorkDrive 中支持的文件

      支持转换的文件 Zoho 内置的 Office Suite 可帮助您分别使用 Writer、Sheet 和 Show 来编辑文档、电子表格和演示文稿。(了解详情) 您可以上传不同格式的文件(如 .docx、.pptx 或 .xlsx 格式),然后将这些文件转换为 Zoho 格式(Writer、Sheet 或 Show),从而在您的 WorkDrive 帐户中为文件创建新副本。 支持转换的文件格式 文档文件 .Doc、.docx、.txt、.rtf、.docm、.dot、.dotm、.dotx 和 ...