Unable to update a Summary field of type DATE using the C# SDK
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 .
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
Comments
-
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
Categories
- All Categories
- 14 Welcome to the Community
- 10.8K Get Help
- 65 Global Discussions
- 69 Industry Talk
- 385 Announcements
- 3.6K Ideas & Feature Requests
- 56 Brandfolder
- 125 Just for fun
- 50 Community Job Board
- 464 Show & Tell
- 40 Member Spotlight
- 44 Power Your Process
- 28 Sponsor X
- 234 Events
- 7.3K Forum Archives