Smartsheet SDK: Cannot find column

Hi,


I have run into a rather annoying issue. I am currently writing a sync tool, which will add a column to a sheet, and write a cell value thereafter.

I am using the smartsheet search feature to find a specific value, and then I add or update a specified column. However, the issue I am running into is that a few of the sheets I am processing do not have the required column, nor am I able to add the column using the smartsheet sdk or via browser/frontend.

Add column logic;

__________________________

Column newLocationColumn = new Column {

                      Title = "Location Key",

                      Index = 0,

                      Type = ColumnType.TEXT_NUMBER

                    };

IList<Column> addedColumns = client.SheetResources.ColumnResources.AddColumns(

                       (long)result.ParentObjectId,

                       new Column[] { newLocationColumn }

                      );

__________________________

Get column logic

___________________________

PaginatedResult<Column> lstColumns = client.SheetResources.ColumnResources.ListColumns((long)result.ParentObjectId, null, new PaginationParameters(true, null, null), 2);

__________________________

If I try and add the column 'Location Key', I get the below error messages.


Regards,

Kevin


Answers

  • Well, after testing the unobvious.. I added a .ToLower() on my column name check.

    ____

    long colUpdateId = lstColumns.Data.Where(x => x.Title.ToLower() == "ColumnName".ToLower()).Select(x => x.Id).FirstOrDefault() ?? 0;

    ____

    This is probably due to typo's..