Activities
latest
false
Banner background image
Classic Integrations Activities
Last updated Mar 22, 2024

Quickstart: Working With Rows

Overview

The purpose of this guide is to walk you through several examples of how to work with Rows on a Sheet in Smartsheet. We will use the following activities:

This working sample enables you to Get a list of rows then iterate through that list of rows, first getting any attachments for that row and then updating a value in that row.

After completing the steps in this guide, you'll have an automation sequence that does the following:

  1. Establishes a connection to your Smartsheet instance (Smartsheet Scope).
  2. Gets a list of rows from a sheet (List Rows).
  3. For each row retrieved, do the following:
  4. Get the attachments for that row (List Rows).
  5. Downloads any attachments on that row Get Attachment.
  6. Updates the value of that row Update Rows.

For item 4 above, we could instead opt to create a Row[] object and make a single Update call, but for the purposes of this demo will will call it once for each Row that we want to update.

Below is a screenshot of what our sample Sheet looks like.



To get your Sheet ID go to File->Properties and see the SheetID. It should look something like 5903706102228868.

Prerequisites

Before you begin:

  1. Complete the Smartsheet Setup steps.
  2. A local folder path to download attachments to.

Steps

Build your project
  1. Create and enter a String variable for your API Token value (e.g., apiToken).
  2. Add the Smartsheet Scope.
  3. For Authentication Type, choose API Token.
  4. Enter your apiToken variable as the value for the API Access Token value.
Create and set variables that will be used in several activities
  1. Create and enter an Int64 variable for your SheetId value (e.g., sheetId).
  2. Create and enter a String variable for your Download Path value (e.g., downloadPath).
Get a List of Rows that we want to get attachments for and also update, and set up a for each loop.
  1. Add the List Rows activity.
  2. Click the Configure button inside the List Rows activity.
  3. For the field Sheet Id, enter your sheetId in to the Value column.
  4. For the field Rows, create a Row[] variable (e.g., rowsRetrieved).
  5. Click the Done button.
  6. Add a For Each activity after the List Rows activity.
  7. For the Values property, enter your rowsRetrieved variable.
  8. For the Type Argument property, use Smartsheet.Api.Models.Row.
  9. In the body of the For Each activity, add a List Rows activity.
  10. For SheetId enter your sheetId variable.
  11. For RowId enter "item.Id.value".
  12. For Include choose "Attachments" as an option.
  13. For Row, create and enter a Row variable (e.g., rowRetrieved)




Set up an If condition check
  1. Add an If* Activity after the Get Row activity.
  2. For the Condition use the value "RowRetrieved.Attachments is Nothing".
  3. In the Else section of the If activity, add a For Each Activity
  4. In the For Each activity, set the following properties:
  5. For Values, set it to rowRetrieved.Attachments (presuming you are using rowRetrieved as your output variable per 7d above).
  6. For TypeArgument set it to "Smartsheet.Api.Model.Attachment"
  7. Rename the ForEach variable from item to attachment.
For each row with an attachment, download the attachment and update a value on that row
  1. Add a Get Attachment activity.
  2. For SheetId, enter your sheetId variable.
  3. For AttachmentId, enter "attachment.Id.Value"
  4. For Download Folder Path, enter your downloadPath variable.
  5. Add an Assign activity after the Get Attachment activity
  6. For To, create a Row variable (e.g., rowUpdate).
  7. For Value, create a new Row object and set it using code similar to the pattern below.
    New Row() With { 
    .Id = RowRetrieved.Id,
    .Cells = New List(Of Cell) From {
        New Cell() With {.Value = '100', .ColumnId = RowRetrieved.Cells(3).ColumnId}
        }
    }New Row() With { 
    .Id = RowRetrieved.Id,
    .Cells = New List(Of Cell) From {
        New Cell() With {.Value = '100', .ColumnId = RowRetrieved.Cells(3).ColumnId}
        }
    }


  8. Add an Update Rows activity after the Assign activity.
  9. Click the Configure button.
  10. For the Sheet Id field, use the sheetId variable.
  11. For the Rows field, click on the Row link button.
  12. Click on the Add button
  13. Enter the rowUpdate variable that you created earlier.
  14. Click the Done button

You're done!

To learn more about the Smartsheet activities (including example property inputs/outputs), see the Activities page for a complete activity list and links to the activity detail pages.

You can download a copy of this robot at the following link:

  • Overview
  • Prerequisites
  • Steps

Was this page helpful?

Get The Help You Need
Learning RPA - Automation Courses
UiPath Community Forum
Uipath Logo White
Trust and Security
© 2005-2024 UiPath. All rights reserved.