Unable to update a Summary field of type DATE using the C# SDK

Helena C
Helena C
edited 12/09/19 in API & Developers

Hi Smartsheet Community!

This is my first post and I hope not to scare you away.

I've been finding the community amazingly helpful in everything I've been doing so far. Now I'm blocked and I hope someone can give me a hand smiley.

 

I'm trying to set a Summary field "Project Due Date" across multiple sheets.This Summary field is of type DATE.

It works fine when I try it via the REST API in Postman.

This is the request:

PUT https://api.smartsheet.com/2.0/sheets/{sheetId}/summary/fields

This is the request body, where the ID belongs to a summary field of type DATE: 

[

    {        

            "id": {summaryFieldId},

                   "objectValue": {

                       "objectType": "DATE",

                       "value": "2019-11-20"

                   }

    }

]

This works perfectly fine: the summary field gets updated to the value "11/20/19" in my UI (see attached image).

 

Now, when I try to do this through the API using the C# SDK, the program runs smoothly but the summary field remains empty.

Below is the code. I cannot figure out what I'm doing wrong. Your help is much appreciated!

 

SummaryField fieldToUpdate = new SummaryField();

fieldToUpdate.Id = {summaryFieldId};

fieldToUpdate.ObjectValue = new DateObjectValue(ObjectValueType.DATE, "2019-11-20");

List<SummaryField> updateSummaryFields = new List<SummaryField>();

updateSummaryFields.Add(fieldToUpdate);

IList<BulkItemFailure> failedResults = new List<BulkItemFailure>();

failedResults = smartsheet.SheetResources.SummaryResources.UpdateSheetSummaryFieldsAllowPartialSuccess({sheetId}, updateSummaryFields, false).FailedItems;

 

Note:

It works fine with summary fields of type TEXT_NUMBER, where I'm using the following code:

fieldToUpdate.ObjectValue = new StringObjectValue("a string");

 

Regards

Helena

Screen Shot 2019-10-18 at 15.27.55.png

Comments

  • timwells
    timwells Employee

    Hi Helena,

    I am able to get pretty similar code to perform as expected. Is it possible you do not have unique title names for the summary fields in your sheet? Can you post the error message you are receiving?

    Thanks,

    Tim