Filter options in smartsheet API or SDK

1.1k views Asked by At

I am currently exploring the smartsheet API 2.0. I want to filter based on Modified and Created date but I am unable to find any such option in the documentation.

Is there a way out to filter the smartsheet using any custom filter as we have in oData API. e.g <API URL>?$filter= createdDate ge '10/06/2019' or modified ge '10/06/2019'

3

There are 3 answers

0
Ilker Baltaci On

You need to create your filters in smartsheet since they can not be created on wire over API. Then you can call

https://api.smartsheet.com/2.0/sheets/{id}?filterId={ID}&exclude=filteredOutRows

P.S You need to enter id of your filter not the name of the filter.

1
Software2 On

You can create a sheet filter, and then filter the rows via the API using the include=filters param.

See the docs for more details.

0
Etienne Mermillod On

There isn't any way to send a filter query, some alternatives :

  • You can create a filter on the fly such as described below.
  • Or you can read all the sheet content and then filter on you own

In c# filtering row would look like this:

var ssclient = new SmartsheetBuilder().SetAccessToken(token).Build();
m.Sheet sheet = ssclient.SheetResources.GetSheet(sheetId, null, null, null, null, null, null, null);
List<m.Row> rowsModifiedToday = sheet.Rows.Where(r => DateTime.ParseExact(r.Cells[columnIndex].Value.ToString(), "dd/MM/yy", null) >= DateTime.Today).ToList();