onDocumentUpdateFreshserviceFreshservice for MSPsFreshservice for business teams
A document can be generated from a document template, enabling a ticket to share data or to submit a ticket workflow. The workflows can have information such as an agreement or approval note. After a template is linked to a service request item, each ticket created from that item has the option to generate a document, which is automatically filled with the ticket’s data. To learn more, see Document generation for employee requests.
The onDocumentUpdate event is triggered in the Freshworks system in the following scenarios:
- A document is generated for a ticket
- When a signer is requested to sign an e-sign document.
- When a signer signs an e-sign document.
- After all signers have signed the document and a document is generated.
Subscribe to the onDocumentUpdate event and register the callback by using the following sample manifest.json content.
"events": {
"onDocumentUpdate": {
"handler": "onDocumentUpdateCallback"
}
}Define the corresponding callback by using the following sample server.js content:
exports= {
onDocumentUpdateCallback: function(payload){
console.log("Logging arguments from onDocumentUpdate event: "+ JSON.stringify(payload);
}
}Attributes of the data object
- actorobject
Information pertaining to the system, agent, or requester who triggered the onDocumentUpdate event in the Freshservice system.
- idinteger
Identifier of the actor who triggered the product event.
- namestring
Full name of the actor who triggered the product event.
- associationsobject
All associated objects of the document object, which specify additional information pertaining to the document updated.
- attachmentobject
Information pertaining to the attachment associated with the document.
- namestring
Name of the attachment file.
- content_typestring
Type of the attachment file.
- sizeinteger
Size of the attachment file.
- expiring_urlstring
The URL of the attachment file. Note:The URL of the attachment file is an s3 URL, which expires within 15 mins.
- changesobject
Changes that triggered the onDocumentUpdate event, specified as a JSON object of the following format:
"changes": { //For non-array attributes "<document.attribute that changed>": ["Old value", "New value"] } - documentobject
Information pertaining to the document updated.
- idinteger
Identifier of the document object, auto-generated when a document is generated for a ticket in the Freshservice system.
- created_atstring
Timestamp indicating when the document was created, specified in the ISO-8601 format.
- updated_atstring
Timestamp indicating when the document was last updated, specified in the ISO-8601 format.
- activeboolean
Specifies whether the document generated is active or not.
Possible values: true, false
- statusstring
Status of the document.
- storage_metaobject
Information pertaining to the storage-related metadata of the document.
Note:The storage_meta object is a part of the onDocumentUpdate only when the template had storage configured at the time the document was generated. If the template didn’t have storage configured, the payload will not include storage_meta will not be part of the object.
- storage_app_namestring
Name of the storage app in which the document is uploaded.
- storage_file_pathstring
Path of the storage where the document will be uploaded.
- storage_statusstring
Status of document uploading process.
Possible values: upload_success , upload_failed, null
- storage_dynamic_folder_pathstring
Folder path in which the document will be located once it gets uploaded. The path is auto-generated based on the storage attributes configured in the Freshservice system.
- ticket_idinteger
Identifier of the ticket in which the document was generated.
- versioninteger
Version of the document.
- workspace_idinteger
For a Freshservice for MSPs product account, workspace_id refers to the identifier of the client associated with the ticket for which the document is generated.
For a Freshservice product account with workspaces, tickets belong to specific workspaces. A workspace is a configurable, team or department-specific space where team-members can collaborate while maintaining the operational integrity of team-only data. workspace_id is the identifier of the workspace associated with the ticket for which the document is generated. It is auto-generated when a new workspace is created in Freshservice. For information about workspaces, read What is a workspace. To retrieve all the workspaces that are created in an account, through APIs, use the List all workspaces API.
Note:workspace_id is displayed as part of the account URL when you (or the app user) navigate to the admin settings of the workspace. For example, when you navigate to the primary workspace’s admin settings, if the corresponding URL is /ws/2/admin/home, the workspace’s ID is 2. - workspace_namestring
For a Freshservice for MSPs product, workspace_name refers to the name of the client associated with the ticket for which the document is generated.
For a Freshservice and Freshservice for Business Teams products, workspace_name refers to the name of the workspace associated with the ticket for which the document is generated.