class CurrencyList
A SharePoint entity class that provides access to the list of supported currencies in SharePoint currency columns.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/lists/currency.py
9 - 25
simple
Purpose
CurrencyList is a specialized Entity class designed to retrieve currency information from SharePoint. It provides a static method to fetch a collection of all currencies allowed in SharePoint currency columns, including their display strings and Locale IDs (LCIDs). This class is part of the Office365 SharePoint API and is used when working with currency-related data in SharePoint lists and columns.
Source Code
class CurrencyList(Entity):
"""List of supported currencies."""
@staticmethod
def get_list(context):
"""
Generates a list of all the currencies allowed in SharePoint currency columns.
The list contains CurrencyInformation objects with display strings and LCIDs for each currency.
:type context: office365.sharepoint.client_context.ClientContext
"""
return_type = ClientResult(context, CurrencyInformationCollection())
qry = ServiceOperationQuery(
CurrencyList(context), "GetList", None, None, None, return_type, True
)
context.add_query(qry)
return return_type
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
Entity | - |
Parameter Details
context: A ClientContext instance representing the SharePoint connection context. This is required for making API calls to SharePoint and managing the request/response lifecycle. The context contains authentication information and the site URL.
Return Value
The class itself inherits from Entity and doesn't return anything on instantiation. The get_list() static method returns a ClientResult object containing a CurrencyInformationCollection, which holds CurrencyInformation objects with display strings and LCIDs for each supported currency. The result is populated asynchronously after the query is executed through the context.
Class Interface
Methods
get_list(context) -> ClientResult
static
Purpose: Retrieves a collection of all currencies allowed in SharePoint currency columns, including their display strings and LCIDs
Parameters:
context: ClientContext instance representing the SharePoint connection context, used to execute the service operation query
Returns: ClientResult object containing a CurrencyInformationCollection. The collection is populated after calling context.execute_query() and can be accessed via the value property of the ClientResult
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
context |
ClientContext | Inherited from Entity base class. Stores the SharePoint client context used for API operations | instance |
Dependencies
office365-rest-python-client
Required Imports
from office365.sharepoint.lists.currency_list import CurrencyList
from office365.sharepoint.client_context import ClientContext
Usage Example
from office365.sharepoint.client_context import ClientContext
from office365.sharepoint.lists.currency_list import CurrencyList
from office365.runtime.auth.user_credential import UserCredential
# Setup authentication and context
site_url = 'https://yourtenant.sharepoint.com/sites/yoursite'
credentials = UserCredential('username@domain.com', 'password')
ctx = ClientContext(site_url).with_credentials(credentials)
# Get the list of supported currencies
currency_result = CurrencyList.get_list(ctx)
ctx.execute_query()
# Access the currency information collection
currencies = currency_result.value
for currency in currencies:
print(f"Currency: {currency.display_string}, LCID: {currency.lcid}")
Best Practices
- Always call ctx.execute_query() after calling get_list() to actually execute the query and populate the result
- The get_list() method is static, so you don't need to instantiate the CurrencyList class to use it
- Ensure the ClientContext is properly authenticated before calling get_list()
- The returned ClientResult object's value property will only be populated after execute_query() is called
- This class is typically not instantiated directly by users; use the static get_list() method instead
- Handle potential authentication and network errors when executing queries
- The CurrencyList instance created internally is used only for query construction and is not meant for direct manipulation
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class FieldCurrency 76.3% similar
-
class CurrencyInformationCollection 75.0% similar
-
class CurrencyInformation 61.4% similar
-
class ListItemCollection 60.8% similar
-
class FavoriteLists 59.6% similar