Upload File

Table of Contents

Overview

This JS API task updates a file to a File upload, Image, Audio, Video, or Signature field of a specific record, in a Zoho Creator application. The upload operation will be subject to the custom data validations configured for the corresponding form.

This V2 task is based on the Upload File REST API V2.1.

Request Details

Syntax

ZOHO.CREATOR.FILE.uploadFile(config).then(function(response){
   //callback block
});

Syntax Details

The syntax holds:

  • <config> (object) - The configuration required to upload a file to a specific record of a report. This configuration includes the following parameters.
NameTypeDescription
app_name
(Optional)
string

Link name of the application to which a file has to be uploaded. Retrieve the link name using the Creator form's URL: https://creatorapp.zoho.com/<account_name>/<app_name>/#Form:<form_name>

Note: This parameter has to be passed only when you need to push data into other applications of the same Creator account. When not specified, data will be pushed to current application.
report_namestringLink name of the report whose record needs to be updated. Retrieve the link name using the Creator report's URL: https://creatorapp.zoho.com/<account_name>/<app_name>/#Report:<report_name>
idstringThe ID of the target record that you want to upload the file to.
field_namestring

The link name of the target field to which the file needs to be uploaded. The field link names can be found in the field properties pane of each field in the form builder.
Supported target fields: File upload, Image, Audio, Video, or Signature field

Note: If the target field (field inside subform) is situated inside a subform field (field in main form), the field_name will be <targetfield_link_name.subformfield_link_name>.

parent_id
(Optional)
stringIf the target field is situated inside a subform, then the parent_id is the ID value of the parent record. This means the main form's record in which the subform has been embedded.
fileobjectIt is a javascript file object to be uploaded.
skip_workflow
(Optional)
list

Prevents the associated workflows from being executed when the file is uploaded to a record.
Possible values: form_workflow, schedules, all

Note: By default:

  • When more than one type of workflow is mentioned, supply them as comma-separated values in a list. For example,
    "skip_workflow" : ["schedules","form_workflow"]
  • If this parameter is not supplied, all associated workflows will be triggered.
  • Blueprints and approvals will be triggered when the file is uploaded and cannot be skipped.

File Size Limits

  • The Image and Signature fields can accept an image that doesn't exceed 10 MB.
  • The File upload, Audio, and Video fields can accept a file that doesn't exceed 50 MB.
  • The file you upload will be counted towards the file storage limit of the account in which the target application exists. Visit the account's Billing page to view its current storage details.

Possible Errors

Refer to this page for the complete list of error codes and messages.

Sample Input

Copiedvar fileObject = document.getElementById("fileInput").files[0];
var config = {
  app_name: "zylker",
  report_name: "All-Timesheet",
  id : "2000000193171",
  field_name : "Attachments",
  file : fileObject
};
ZOHO.CREATOR.FILE.uploadFile(config).then(function (response) {
  console.log(response);
});

Sample Response

Copiedresponse  = {
   "code": 3000,
   "data": {
       "filename": "Rental Agreement-March.pdf",
       "filepath": "1587402896598_Rental_Agreement-March.pdf",
       "message": "success"
    }
 }