Calculated Field Formula localization | AddFieldAsXml
Target SharePoint environment
SharePoint Online
What SharePoint development model, framework, SDK or API is this about?
SharePoint CSOM
Developer environment
None
What browser(s) / client(s) have you tested
- [ ] 💥 Internet Explorer
- [x] 💥 Microsoft Edge
- [ ] 💥 Google Chrome
- [ ] 💥 FireFox
- [ ] 💥 Safari
- [ ] mobile (iOS/iPadOS)
- [ ] mobile (Android)
- [ ] not applicable
- [ ] other (enter in the "Additional environment details" area below)
Additional environment details
Latest version of CSOM, PnP PowerShell or just REST API
Describe the bug / error
Something has changed in the behavior when adding SharePoint Fields (in this case using a provisioning engine) - I have a site with LCID 1030 (Danish) - and normally I would add the following field to the site
SchemaXML
<Field Type="Calculated" DisplayName="Week" EnforceUniqueValues="FALSE" Indexed="FALSE" Format="DateOnly" LCID="1030" ResultType="Text" Group="REDACTED" ID="{cb738292-b734-4866-8d94-edf6886348f6}" SourceID="{389dbd9b-06d5-4681-aa62-a996395fffdc}" StaticName="REDACTED_Week" Name="REDACTED_Week" CustomFormatter="" Required="FALSE" AllowDeletion="TRUE" Version="8" ReadOnly="TRUE"><Formula>=INT(([Report Date]-DATE(YEAR([Report Date]-WEEKDAY([Report Date]-1)+4),1,3)+WEEKDAY(DATE(YEAR([Report Date]-WEEKDAY([Report Date]-1)+4),1,3))+5)/7)</Formula></Field>
However when I now add that SiteField to a list I get an exception, investigating a bit further, it turns out that the ListFields formulas are now translated to the locale of the site, while the site fields aren't
Resulting in the following List field SchemaXML
<Field Type="Calculated" DisplayName="Week" EnforceUniqueValues="FALSE" Indexed="FALSE" Format="DateOnly" LCID="1030" ResultType="Text" Group="REDACTED" ID="{cb738292-b734-4866-8d94-edf6886348f6}" SourceID="{389dbd9b-06d5-4681-aa62-a996395fffdc}" StaticName="REDACTED_Week" Name="REDACTED_Week" CustomFormatter="" Required="FALSE" AllowDeletion="TRUE" Version="6" ReadOnly="TRUE" ColName="sql_variant1" RowOrdinal="0"><Formula>=INT((REDACTED_ReportDate-DATE(YEAR(REDACTED_ReportDate-WEEKDAY(REDACTED_ReportDate-1)+4),1,3)+WEEKDAY(DATE(YEAR(REDACTED_ReportDate-WEEKDAY(REDACTED_ReportDate-1)+4),1,3))+5)/7)</Formula><FieldRefs><FieldRef Name="REDACTED_ReportDate" /></FieldRefs></Field>
The key difference I notice is the formula is now translated
SiteField
=INT(([Report Date]-DATE(YEAR([Report Date]-WEEKDAY([Report Date]-1)+4),1,3)+WEEKDAY(DATE(YEAR([Report Date]-WEEKDAY([Report Date]-1)+4),1,3))+5)/7)
ListField
=HELTAL(([Report Date]-DATO(ÅR([Report Date]-UGEDAG([Report Date]-1)+4);1;3)+UGEDAG(DATO(ÅR([Report Date]-UGEDAG([Report Date]-1)+4);1;3))+5)/7)
This unpredictable experience makes it really hard to work with, I know from chatting with @KasperBoLarsen he's been struggling with the same thing when pulling content-types from the content-type hub
Steps to reproduce
- Create a site column and content-type in the content-type hub
- Use them on a site in a different language than the hub
- Cry
Expected behavior
I would expect consistent formulas within the site, I believe in the past the API would always just accept english, this seems like a change (perhaps related to knowledge agent) on the lists/library columns
Hello @Tanddant, Thank you for bringing this issue to our attention. We will look into it and get back to you shortly.
I was able to reproduce this behavior on a Danish (LCID 1030) site.
I will engage the engineering team to confirm whether this is expected localization behavior (UI/server-side) or if it should be considered a regression.
We are experiencing the same issue in our Dutch tenant: calculated column formulas suddenly have to be entered in Dutch instead of English. As a result, our product that provisions sites no longer works.
When can we expect a concrete response on this? Otherwise, we will have to adjust our code for something that may not be permanent.
My current workaround is to change this formular to something like generic like =IF((1 =2), "NFG","NA") , just in order to ensure that the provisioning doesn't fail, and then run a script that updates the formula in the correct language. At least it works
Hi,
Does anyone has any updates on this issue?
Hi, we are also experiencing the same issue across multiple tenants. It looks like the regional languagecode withun the site settings has suddenly changed. This is why the formula needs to be different, while in English and for example Dutch the formula seperator is different , vs ; Setting back the region languagecode to the oriinal value will solve the issue. Not sure why the region languagecode within the settings suddenly has changed within multiple sites on multiple tenants....
I'm now also facing this issue when pulling a Content Type from the Content Type where there's a column using a default value that's a formula.
@danielpastoor , @kasperbolarsen and @SanderSiep - let's see if you can help us on this a bit to provide a bit more details on the situation in your tenant.
What's the tenant default language where this issue has existed? - What's the language in the content type hub? - What about the site where issue exists?
We are trying to find the exact details for the repro - without good progress. Thanks for your input advance.