Attach File

Attach File

Description

The zoho.crm.attachFile task is used to attach a file with the specified record in Zoho CRM.

Syntax

<response> = zoho.crm.attachFile(<module>,<record_id>,<file_object>);

where,

ParamsDescriptionData type

<response>

specifies the response message returned by Zoho CRM. It represents the record's creation and modification details against the API names of the respective fields and the status of the task.

MAP

<module>

specifies the API name of the module that contains the record to which the file needs to be attached

Note: Refer this for the instructions to get API names of the CRM modules and fields.

STRING

<record_id>

specifies the ID of the record to which the file needs to be attached.

BIGINT

<file_object>

specifies the attachment file

FILE


Example

The following script attaches the file - file_object, to the record with ID - 4770XXXXXXXXXX in the Zoho CRM module - Leads.

 file_object = invokeUrl
 [
 url: "https://assets.pcmag.com/media/images/431075-zoho-logo.jpg?width=810&height=456"
 type: GET
 ];
 response = zoho.crm.attachFile("Leads",4770XXXXXXXXXX,file_object);

where,

response
is the response returned by Zoho CRM, which represents the creation and modification information of the record and the status of the task.
"Leads"
is the name of the module that contains the record to which the file needs to be attached
4770XXXXXXXXXX
is the NUMBER that represents the record ID
file_object
is the FILE variable that holds the attachment file

Response Format

The response returned is of the following format:

{
"code": "SUCCESS",
"details": {
"Modified_Time":  <Date/Time in ISO 8601 format>,
" "Modified_By": {
"name": <User_Name>,
"id": <user_id>
},
"Created_Time": <Date/Time in ISO 8601 format>,
"id": <id of the record created>,
"Created_By": {
"name": <User_Name>,
"id": <user_id>
}
},
"message": "attachment uploaded successfully",
"status": "success"
}

The following is a sample response returned after a file has been attached

{  
"code":"SUCCESS",
"details":{  
"Modified_Time":"2018-12-11T12:20:45+05:30",
"Modified_By":{  
"name":"John",
"id":"4770XXXXXXXXXXXXXXX"
},
"Created_Time":"2018-12-11T12:20:45+05:30",
"id":"4770XXXXXXXXXXXXXXX",
"Created_By":{  
"name":"John",
"id":"4770XXXXXXXXXXXXXXX"
}
},
"message":"attachment uploaded successfully",
"status":"success"
}

The failure response returned for incorrect or non-existent record ID is of the following format:

 {
 "code":"INVALID_DATA",
 "details":{},
 "message":"the related id given seems to be invalid",
 "status":"error"
 }

Share this post : FacebookTwitter

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

Write to us: support@zohocreator.com