Auto export created attachment to local folder
Is there a way to automatically save/export a created document to a local folder?
I have a .pdf that is generated through a workflow, but I need the pdf generated also saved in a local folder with a file name specific to the generated document (Equip#_Created Date)
For example, I have a folder for a specific piece of equipment already made locally. I would want this process to save any new documents for this equipment to go into this folder. Unique identifier would be a created date.
If I did this in Excel it would look something like this:
C:\Users\Desktop\Equip#_Created Date
I hope Im explaining this ok. I need this document local because not everyone can access Smartsheet and we need these generated docs for audits. So they need to be able to readily accessed from a folder on a desktop/laptop.
Thanks for the help.
Answers
-
Hi @dhallarcosa
First, get the sheet and loop over rows to get attachments.
Example:
from https://smartsheet.redoc.ly/tag/attachments
# Sample 1: List all response = smartsheet_client.Attachments.list_row_attachments( 2252168947361668, # sheet_id 4293147074291588, # row_id include_all=True)
Then, from the response, get the attachment_id and using it, get attachment_url.
Example:
attachment = smartsheet_client.Attachments.get_attachment(
9283173393803140, # sheet_id
4583173393803140) # attachment_id
The attachment_url is attachment.url, attachment_name is attachment.name, and the time attachment is created is attachment.created.
Then, using those, download the file with proper filename, attachment_name + str(attachment.created), for example.
Here is a sample code, using Smartsheet Python SDK, run on Google Colab.
Categories
- All Categories
- 14 Welcome to the Community
- Smartsheet Customer Resources
- 64.2K Get Help
- 419 Global Discussions
- 221 Industry Talk
- 461 Announcements
- 4.8K Ideas & Feature Requests
- 143 Brandfolder
- 142 Just for fun
- 58 Community Job Board
- 462 Show & Tell
- 32 Member Spotlight
- 1 SmartStories
- 299 Events
- 38 Webinars
- 7.3K Forum Archives