Creating and Formatting Sheet Summary Field with API using Python
I am updating a handful of sheet summaries using Python. My current code creates the sheet summary fields that I want with the correct formulas however I am unable to get the formatting to work properly. Below is a partial screenshot of the code:
According to the API docs I should be able to set the formatting of the sheet summary value since 'format' is part of the SummaryField objects.
I did create the object currenctFormat (line 6) which is set to be USD with zero decimal places ($0). I have also tried not using the currencyFormat object and putting the format string directly in the code (line 22). While the code runs and I have no errors, the formatting is the default (0) and not what I am trying to set it to ($0). Below are screenshots of my run log as well as the newly created sheet summary field:
Note: in the above screenshot ‘Current Week – Value of Jobs WON’ was previously created manually
Answers
-
Hi @Garrett Henke,
On the API documentation about Formatting there is a note that asks to return the the FormatTables object to be able to identify the default settings and what are the formatting options available. This is advised because the formatting can change at any time.
In further research, I found a similar issue was experienced by other Smartsheet user when formatting cells in the Smartsheet app and was able to resolve with the following methods: GET ROW (before cell format update); UPDATE ROW (cell format); GET ROW (after cell format update). In this case you may try with Get Summary Fields; Update Summary Fields; Get Summary Fields from the Sheet Summary method list. You can review this post for your reference on the reported problem with applying currency formats to cells that seemed to resolve the matter.
I hope this can offer some guidance.
Cheers!
Julio
-
@Julio S. I have tried the above and the formatting is still not showing correct within the sheet summary.
-
Hi @Garrett Henke,
I can see you've also opened a ticket with our Support team where you've been referred to Stack Overflow which I'd also recommend as the best resource for API and coding questions.
If returning the FormatTables doesn't seem to fully work as a solution, I'd recommend following up on your case with Support and adding some screenshots of your current code trying to return the FormatTables and applying them. Please note that although Support won't be able to write code for you, they will most certainly be able to troubleshoot any API call or error you may see.
Cheers!
Julio
-
I know the question is one year old, but to provide a proper answer:
Try adding the formatting to each field:
summ_fld = ss.models.SummaryField()
summ_fld.format = ",,,,,,,,,,,,,1,2,,"
summ_fld.type = 'TEXT_NUMBER'
summ_fld.title = 'Contract amount'
summ_fld.value = 0
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 64.6K Get Help
- 433 Global Discussions
- 136 Industry Talk
- 466 Announcements
- 4.9K Ideas & Feature Requests
- 143 Brandfolder
- 147 Just for fun
- 64 Community Job Board
- 466 Show & Tell
- 32 Member Spotlight
- 2 SmartStories
- 298 Events
- 36 Webinars
- 7.3K Forum Archives