Smartsheet API parentId location specifier doesn't work?

I have a function used to make parent-child relationships in smartsheet.

The child_df contains the row and parent info, when I call update rows, it reads my row ID to update (row.id) and if I pass in the argument row.to_bottom = True it also works, but it stubbornly doesn't assign a parent ID when I pass parentId into the row.


When I removed the row and added the row with only a parentId specified, it gave me an error that it required at least one location specifier (which parentId should be one).

Code below:

for i in range(0,len(child_df)):

       row = smartsheet_API.models.Row()

       row.parentId = child_df.iloc[i]['Parent']

       row.id = child_df.iloc[i]['Row']

       row.cells = [{'column_id': column_map[source_column],              

             'value': self.convert(source_df.loc[i, source_column],source_column)}              

             for source_column in source_df.columns.values]

       new_rows.append(row)

response = self.ss_API.Sheets.update_rows(sheet_id,new_rows)

Answers

  • Krissia B.
    Krissia B. Moderator

    Hello @Jason R Dong

    Upon reviewing your post, I recommend visiting the link here. There's some pretty well-defined notes regarding parent and location for the specifics you are encountering such as:

    • Use only one location-specifier attribute per request, unless you use parentId and toBottom or siblingId and above.
    • If you specify multiple rows in the request, all rows must have the same location-specifier attributes.
    • If you specify the parentId attribute, you cannot also specify the siblingId attribute.
    • If you specify the siblingId attribute, you cannot also specify the parentIdtoTop, or toBottom attributes.
    • If you want to indent or outdent multiple rows, use the parentId attribute.


    Hope this helps!

    Cheers,

    Krissia