JS SDK

JS SDK

Prerequisite

Include the JS http://js.zohostatic.com/projects/marketplace_apps/1.0/js/client_sdk.min.js in your code before calling the following SDK methods.

init

Initializes the extension.


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

Invoking this method at the beginning is necessary since the other SDK methods will work only after its invocation.

metadata

Fetches the payment and configuration details of an extension.

zohoprojects.metadata().then(function(response)
{
console.log(response);
/* output
{
  "data": {
    "configs": [
      {
        "name": "Name",
        "type": "text",
        "is_mandatory": true,
        "is_secure": false,
        "description": "Enter your name",
        "value": "Helen Collins"
      },
      {
        "name": "Employee ID",
        "type": "text",
        "is_mandatory": true,
        "is_secure": false,
        "description": "Enter your Emp. ID",
        "value": "EMP08"
      }
    ],
    "payments_info": {
      "edition": "trial"
    },
    "status": "success"
  }
}
*/
});

context

Fetches the module name and entity ID of the current location. The module name is 'tasks' or 'issues' and the entity ID is the ID of the respective task or issue.


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

 

We do not give the entity ID for the widget location 'app_settings'.

get

Fetches the details of the instances, current user, portal, project, tasks, and issues of the current location.


zohoprojects.get("task.id").then(function(response)
{
/* output
{
  "data": 27092000000031080,
  "status": "success"
}
*/
});

The following are the list of keys that can be used in the get method:

Instances

  • instances

Current user

  • current_user

Portal

  • portal.trial_enabled
  • portal.settings
  • portal.gmt_time_zone
  • portal.project_count
  • portal.role
  • portal.avail_user_count
  • portal.locale
  • portal.project_prefix
  • portal.available_projects
  • portal.max_user_count
  • portal.profile_id
  • portal.name
  • portal.id_string
  • portal.id
  • portal.bug_plural
  • portal.plan

Project

  • project.is_strict
  • project.role
  • project.bug_count
  • project.owner_id
  • project.taskbug_prefix
  • project.link
  • project.description
  • project.milestone_count
  • project.updated_date_long
  • project.task_count
  • project.updated_date_format
  • project.workspace_id
  • project.billing_status
  • project.id
  • project.key
  • project.is_chat_enabled
  • project.owner_name
  • project.profile_id
  • project.enabled_tabs
  • project.name
  • project.is_public
  • project.layout_details
  • project.status
  • project.permissions

Task

  • task.id
  • task.name
  • task.completed
  • task.created_by
  • task.priority
  • task.percent_complete
  • task.start_date
  • task.end_date
  • task.dependency
  • task.duration
  • task.details
  • task.link
  • task.attachments
  • task.comments
  • task.subtasks
  • task.customfields

Issue

  • issue.module
  • issue.created_time_long
  • issue.customfields
  • issue.status
  • issue.reproducible
  • issue.link
  • issue.severity
  • issue.reported_person
  • issue.id
  • issue.title
  • issue.flag
  • issue.assignee_name
  • issue.reporter_id
  • issue.classification
  • issue.created_time_format
  • issue.closed
  • issue.created_time
  • issue.key
  • issue.attachments
  • issue.comments
  • issue.views

set

Updates the attributes of a specific task or an issue of the current location.


var nameObj={name:"Create a new checklist"};
zohoprojects.set("task",nameObj).then(function(response)
{
/* output
{
  "data": {
    "tasks": [
      {
        "milestone_id": "2*******************2",
        "link": {
          "timesheet": {
            "url": "https://p*************e.********.com/restapi/portal/5******7/projects/2****************9/tasks/2****************9/logs/"
          },
          "self": {
            "url": "https://p*************e.********.com/restapi/portal/5******7/projects/2****************9/tasks/2****************9/"
          }
        },
        "description": "",
        "duration": "0",
        "last_updated_time_long": 1542193097398,
        "details": {
          "owners": [
            {
              "name": "JOHN MARSH",
              "id": "5************3"
            }
          ]
        },
        "id": 2************0,
        "key": "WEUT-T1",
        "created_person": "Steve Banks",
        "created_time_long": 1525668983347,
        "created_time": "05-07-2018",
        "is_reminder_set": false,
        "is_recurrence_set": false,
        "created_time_format": "05-07-2018 10:26:23 AM",
        "subtasks": false,
        "work": "0:00",
        "custom_fields": [
          {
            "column_name": "UDF_LONG1",
            "label_name": "Expense Amount",
            "value": "24573"
          },
          {
            "column_name": "UDF_LONG3",
            "label_name": "sample",
            "value": "0"
          },
          {
            "column_name": "UDF_LONG2",
            "label_name": "test",
            "value": "200"
          }
        ],
        "isparent": false,
        "work_type": "work_hrs_per_day",
        "completed": false,
        "priority": "None",
        "created_by": "5******3",
        "percent_complete": "0",
        "last_updated_time": "11-14-2018",
        "name": "Create a new checklist",
        "id_string": "2************9",
        "last_updated_time_format": "11-14-2018 04:28:17 PM",
        "tasklist": {
          "name": "General",
          "id": "2************7"
        },
        "order_sequence": 1,
        "status": {
          "name": "Open",
          "id": "2************1",
          "type": "open",
          "color_code": ""
        }
      }
    ]
  },
  "status": "success"
}
*/
});

The following keys can be used in the set method for tasks:

Tasks

  • task.person_responsible
  • task.name
  • task.end_date
  • task.percent_complete
  • task.duration
  • task.duration_type
  • task.priority
  • task.description
  • task.start_time
  • task.end_time
  • task.owner_work
  • task.task_duration_as_work
  • task.uploaddoc
  • task.customfields (Used to create and update attributes)
  • task.custom_status
  • task.clear_date
  • task.make_as_task
  • task.json_string
  • task.subtasks (Used to create and update attributes. Click here to know the params for subtasks.)

The following keys can be used in the set method for issues:

Issues

  • issue.title
  • issue.description
  • issue.assignee
  • issue.flag
  • issue.classification_id
  • issue.milestone_id
  • issue.due_date
  • issue.module_id
  • issue.severity_id
  • issue.reproducible_id
  • issue.status_id
  • issue.resolution
  • issue.affectedmile_id
  • issue.uploaddoc

request

Invokes a third-party URL from your extension using the connection defined in the plugin-manifest.json file. If the connection link name is not specified then the response is provided based on the inputs.


var file_detail = {
type: "GET",
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 nameData typeDescription
URLstringThe third-party URL that has to be invoked from your extension.
objectJSONObjectKeyData typeValue
  typestring"GET" / "POST"
  parametersJSONObjectThe request params of the API.
  headersJSONObjectThe headers of the API.
  replace_secure_configBoolean

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

Zoho Projects will replace the value in the URL.

Note: The default value is false.

connection_link_namestringThe connection link name generated from the zapps website.

Share this post : FacebookTwitter

Still can't find what you're looking for?

Write to us: support@zohoprojects.com