---
title: Sub Accounts Data Block
description: "*The SubAccounts (SubAccounts) System Data Block is a System Data Block and is not edited.* The SubAccounts (SubAccounts) Data Block retrieves subaccount information from Assette or client database, based on the specified interface method (`Local` or `BYOD`). It first checks…"
url: "https://learn.assette.com/docs/subaccounts-system-data-block/"
updated: "2024-09-17"
category: Developers / Data Blocks / Data Blocks by Category / System Data Blocks
---

# Sub Accounts Data Block

*The SubAccounts (SubAccounts) System Data Block is a System Data Block and is not edited.*

The SubAccounts (SubAccounts) Data Block retrieves subaccount information from Assette or client database, based on the specified interface method (`Local` or `BYOD`). It first checks for relevant input parameters like `Code`, `AccountCode`, and `AsOfDate`, setting default values if necessary. The SubAccounts (SubAccounts) Data Block then retrieves and processes the subaccount data, ensuring all required fields are present. Finally, it organizes the information into a list of subaccount details and returns it in the response. This Data Block is not edited.

Data Retrieval: The SubAccounts (SubAccounts) Data Block retrieves data based on the `interface_method`:

- **Local**: It queries the `SubAccountsLocalDB` using `AccountCode` and `AsOfDate`.
- **BYOD**: It queries the `SubAccountsClientDB` using the input `params`.

## General Info

*The following table shows the default fields of the Data Block*.

| Field | Value |
| --- | --- |
| Name | SubAccounts |
| Block Category | Transform |
| Block Type | Python |
| Data Category | None |
| Output Type | Data Table |

## Dependencies

*The following table shows the default dependencies of the Data Block*.

| Data Block Name | Description |
| --- | --- |
| CalculationEnv | Used to import Python modules and libraries (e.g., "import numpy as np") [[Link](https://learn.assette.com/docs/calculation-env-data-block/)] |
| SubAccountsLocalDB | The Sub Accounts Local Database (*SubAccountsLocalDB*) Data Block retrieves subaccount information from Assette. This Data Block is not edited. [[Link](https://learn.assette.com/docs/sub-accounts-local-database-data-block/)] |
| SubAccountsClientDB |  |
| GetClientConfigLocalDB | Retrieves the current Assette configurations |

## Columns

*The following columns are the default columns for the Data Object, all columns are optional unless marked otherwise. Please see footnotes for additional information.*

| Name | Data Type |
| --- | --- |
| AccountID | VARCHAR |
| Name | VARCHAR |
| Code | VARCHAR |
| Code | VARCHAR |
| Manager | VARCHAR |
| Strategy | VARCHAR |
| InceptionDate | VARCHAR |
| GroupAccountCode | VARCHAR |
| GroupAccountId | VARCHAR |

* Indicates a mandatory column

## Example Definition

```
AccountCode=""
AsOfDate = ""

if(params.__len__()>0):
    if "Code" in params :
        AccountCode=params["Code"]
    if "AsOfDate" in params :
        AsOfDate = params["AsOfDate"]
    if "AccountCode" in params :
        AccountCode=params["AccountCode"]

if params.get("Code") is None or params.get("Code") =="":
    params["Code"] = AccountCode

interface_method = "Local"
interface_df = pd.DataFrame(read("GetClientConfigLocalDB",{"ParamName":"InterfaceMethod"})["data"])

if interface_df.empty:
    interface_method="Local"
else:
    interface_method=interface_df["ParamValue"].values[0]

#interface_method = read("GetClientConfigLocalDB", {"ParamName":"InterfaceMethod"})["data"][0]["ParamValue"]
outputlist=[]
#IsAccountAttribWithDescription=False

#data_df = pd.DataFrame(read("AccountAttributesLocalDB",{"ID":ID,"Code":Code})["data"])
if interface_method == "BYOD":
    data_df = pd.DataFrame(read("SubAccountsClientDB",params)["data"])
else:
    data_df = pd.DataFrame(read("SubAccountsLocalDB",{"AccountCode":AccountCode,"AsOfDate":AsOfDate})["data"])

if data_df.shape[0]>0:
    if "AccountID" not in data_df.columns:
        data_df["AccountID"]=""
    if "Code" not in data_df.columns:
        data_df["Code"]=""
    if "Name" not in data_df.columns:
        data_df["Name"]=""
    if "Category" not in data_df.columns:
        data_df["Category"]=""
    if "Manager" not in data_df.columns:
        data_df["Manager"]=""
    if "Strategy" not in data_df.columns:
        data_df["Strategy"]=""
    if "Vehicle" not in data_df.columns:
        data_df["Vehicle"]=""
    if "InceptionDate" not in data_df.columns:
        data_df["InceptionDate"]=""
    if "GroupAccountId" not in data_df.columns:
        data_df["GroupAccountId"]=0
    if "GroupAccountCode" not in data_df.columns:
        data_df["GroupAccountCode"]=""

for i in range(0, data_df.shape[0]):
            data_df.loc[i,"ID"]=i
            outputlist.append({ "AccountID":data_df.loc[i,"AccountID"],"Code":data_df.loc[i,"Code"],"Name":data_df.loc[i,"Name"],"Category":data_df.loc[i,"Category"]
                                        ,"Manager":data_df.loc[i,"Manager"],"Strategy":data_df.loc[i,"Strategy"],"Vehicle":data_df.loc[i,"Vehicle"],"InceptionDate":data_df.loc[i,"InceptionDate"],"GroupAccountId":data_df.loc[i,"GroupAccountId"],"GroupAccountCode":AccountCode})

response["data"] = outputlist
```
