How to get attachment names from one smartsheet to another?

Hi,

I have attachments in rows in one of the Smartsheet. I want those attachment names into another Smartsheet. I want this process to be done automatically. Could someone please help me on this.

Thanks In Advance.

Answers

  • Hi @rye

    You can use a workflow to automatically copy rows from one sheet to another; this will copy over the attachments as well. However there currently is no way to use a formula to look at the attachment column and return the names. You may be able to use a third party application or the Smartsheet API to get that data.

    Please submit your feature request to the Product team by creating an Idea Post in the Smartsheet Product Feedback and Ideas topic here in the Community.

    Cheers,

    Genevieve

    Need more help? 👀 | Help and Learning Center

    こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao! 👋 | Global Discussions

  • rye
    rye ✭✭✭

    Hi Genevieve,

    Thank you for your reply. For getting attachment names , I have written a python code to get a list of attachment names in sheet to a local CSV file.

    Python Code:

    import requests
    import csv
    
    # Replace with your Smartsheet API token and sheet ID
    token = 'Your API access key'
    sheet_id = 'Your Sheet ID'
    # Get the list of attachments for all rows
    url = f'https://api.smartsheet.com/2.0/sheets/{sheet_id}/attachments'
    headers = {'Authorization': f'Bearer {token}'}
    response = requests.get(url, headers=headers)
    attachments_data = response.json()
    
    # List to store attachment names
    attachment_names = []
    
    # Loop through attachments and collect names
    for attachment in attachments_data['data']:
        attachment_name = attachment.get('name')
        if attachment_name:
            attachment_names.append(attachment_name)
    
    # Write attachment names to the CSV file
    csv_file_path = 'Local path to your csv files'
    with open(csv_file_path, 'w', newline='') as csvfile:
        writer = csv.writer(csvfile)
        writer.writerow(['Attachment Names'])
        writer.writerows([[name] for name in attachment_names])
    
    print(f"Attachment names saved to {csv_file_path}")