class FieldCurrency
A SharePoint field class that represents currency values, extending FieldNumber with currency-specific formatting capabilities.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/fields/currency.py
4 - 24
simple
Purpose
FieldCurrency is a specialized field type for SharePoint that handles currency values with locale-specific formatting. It inherits from FieldNumber and adds currency locale identifier (LCID) support to properly format monetary values according to regional standards. This class is used when defining or working with currency columns in SharePoint lists and libraries.
Source Code
class FieldCurrency(FieldNumber):
"""Specifies a field (2) that contains currency values. To set properties, call the Update method
(section 3.2.5.43.2.1.5)."""
@property
def currency_locale_id(self):
"""
Gets the language code identifier (LCID) used to format the value of the field.
:rtype: int or None
"""
return self.properties.get("CurrencyLocaleId", None)
@currency_locale_id.setter
def currency_locale_id(self, value):
"""
Sets the language code identifier (LCID) used to format the value of the field.
:type value: int
"""
self.set_property("CurrencyLocaleId", value)
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
FieldNumber | - |
Parameter Details
__init__: Inherits constructor from FieldNumber parent class. The exact parameters depend on the parent class implementation, but typically include field metadata such as name, internal name, and other SharePoint field properties.
Return Value
Instantiation returns a FieldCurrency object that represents a SharePoint currency field. The currency_locale_id property getter returns an integer LCID value or None if not set. The property setter does not return a value (returns None implicitly).
Class Interface
Methods
@property currency_locale_id(self) -> int | None
property
Purpose: Gets the language code identifier (LCID) used to format the currency value
Returns: Integer LCID value if set, None otherwise
@currency_locale_id.setter currency_locale_id(self, value: int) -> None
property
Purpose: Sets the language code identifier (LCID) used to format the currency value
Parameters:
value: Integer LCID value representing the locale for currency formatting (e.g., 1033 for en-US)
Returns: None
set_property(self, name: str, value: Any) -> None
Purpose: Inherited method from parent class to set field properties
Parameters:
name: Property name to setvalue: Value to assign to the property
Returns: None
update(self) -> None
Purpose: Inherited method to persist field changes to SharePoint server
Returns: None
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
properties |
dict | Inherited dictionary containing field properties including CurrencyLocaleId and other field metadata | instance |
Dependencies
office365.sharepoint.fields.number
Required Imports
from office365.sharepoint.fields.currency import FieldCurrency
from office365.sharepoint.fields.number import FieldNumber
Usage Example
# Assuming you have a SharePoint context and list object
from office365.sharepoint.fields.currency import FieldCurrency
# Get an existing currency field from a SharePoint list
currency_field = list_obj.fields.get_by_internal_name_or_title('Price')
# Set the currency locale to US English (LCID 1033)
currency_field.currency_locale_id = 1033
# Update the field on the server
currency_field.update()
ctx.execute_query()
# Get the current locale ID
locale_id = currency_field.currency_locale_id
print(f'Currency locale ID: {locale_id}')
Best Practices
- Always call the Update method after modifying the currency_locale_id property to persist changes to SharePoint
- Use valid LCID values that correspond to actual locale identifiers (e.g., 1033 for en-US, 1036 for fr-FR)
- Ensure proper SharePoint context is established before accessing or modifying field properties
- The currency_locale_id property may return None if not explicitly set, so handle this case in your code
- Inherit from this class if you need to extend currency field functionality with additional properties
- Use the set_property method (inherited from parent) for setting other field properties beyond currency_locale_id
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class CurrencyList 76.3% similar
-
class FieldNumber 70.6% similar
-
class CurrencyInformationCollection 68.5% similar
-
class CurrencyInformation 67.7% similar
-
class FieldCalculated 62.1% similar