SharePoint / SharePoint/sp-dev-docs

Calculated Field Formula localization | AddFieldAsXml

Open
#10,686 8 comments 0 reactions 1 assignee View on GitHub

@Ashlesha-MSFT is already working on this.

Since Mar 2, 2026.

sharepoint-developer-support type:bug-confirmed
Dominant language
PowerShell
Stars
1.4k
Forks
1.1k
Avg merge
4d 12h
Merged PRs (30d)
12

Description

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
  • 💥 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
  1. Create a site column and content-type in the content-type hub
  2. Use them on a site in a different language than the hub
  3. 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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.