> ## Documentation Index
> Fetch the complete documentation index at: https://help.dingtalk.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Builder Functions

> This page describes the structure of the standard User model and Department model, and explains how to use functions such as UserBuilder, DirectorBuilder, DeptBuilder, GetObjectField, and GetArrayItem. These functions generate or process User and Department data.

## Model Overview

* Standard User model object

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
"corpId":"organization ID",
"label":"Name (Employee ID)",
"avatar":"Profile Photo URL",
"key":"userid",
"businessWorkNo":"Work account"
}
```

* Standard Department model object

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
	"label":"Current department name",
	"key":"Department ID"
}
```

## UserBuilder

### Expression

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
UserBuilder(["userid","userid"]  |  ${memberComponent[{},{}]} )
```

<Warning>
  Formula description: User builder function. Generates the User model collection that corresponds to a given userid list or member component.
</Warning>

### Input Parameters

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
(["userid","userid"]  or  ${memberComponent[{},{}]} )
```

### Return Value

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
[{User object},{User object}]
```

### Example

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
UserBuilder(["some_userid_123"])

// Returns
[{user1}]
```

## DirectorBuilder

### Expression

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
DirectorBuilder( "" | "userid", level )
```

<Warning>
  Formula description: Manager builder function. Returns the level-th manager of the current signed-in user or of a specified user. The level parameter must be >= 1. Returns the User model collection of the matching manager(s); multiple managers are returned when the user belongs to multiple departments.
</Warning>

### Input Parameters

* Parameter 1: The userid that identifies the target user. Pass "" to use the current signed-in user.
* Parameter 2: level. Returns the level-th manager. Only valid when level >= 1.

### Return Value

* Standard User model object of the manager: \[\{User object},\{User object}]

### Example

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
DirectorBuilder("",2)

// Returns
[{user1},{user2}]
```

## DeptBuilder

### Expression

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
DeptBuilder(no parameter | userid | single-select member component)
```

<Warning>
  Formula description: Department builder function. Retrieves the specified Department object model based on the input conditions. This formula does not support subforms.
</Warning>

### Input Parameters

Parameter 1 (three modes):

* No parameter: the direct department of the current signed-in user.
* userid: the direct department of the specified user ID.
* Single-select member component: the direct department of the user referenced by that member component.

### Return Value

* Standard Department model object: \[Department object, Department object]. A user can belong to multiple departments at the same time.

### Example

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
DeptBuilder("")
// Returns
[{dept},{user2}]
```

## GetObjectField

### Expression

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
GetObjectField(standard JSON object model, "fieldKey")
```

<Warning>
  Formula description: GetObjectField **is a utility function. JsonObject is a general-purpose standard object storage format that organizes data internally using a key:value structure. GetObjectField returns the value of the specified key from a given standard JSON object.**

  **Note: Not supported inside subforms.**
</Warning>

### Input Parameters

* Parameter 1: The standard JsonObject to read from.
* Parameter 2: fieldKey. The first-level attribute key of the object in parameter 1.

### Return Value

* The value that corresponds to the object's attribute key. Defaults to Text type.

### Example

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
GetObjectField( GetArrayItem(UserBuilder(memberComponent), 1) ,"label")

// Example member component data:
[{"label":"John (Employee ID 11)","key":"userid123"},{"label":"Mary (Employee ID 22)","key":"userid124"}]

// Returns

"John (Employee ID 11)"
```

## GetArrayItem

### Expression

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
GetArrayItem(standard JsonArray type, n)
```

<Warning>
  Formula description: GetArrayItem **is a utility function. JsonArray is a general-purpose standard array collection storage format in which each unit is a standard JsonObject or JsonArray. GetArrayItem returns the n-th data unit (either a JsonObject or JsonArray) from a given standard JsonArray.** n >= 1, where n = 1 refers to the first data unit.
</Warning>

### Input Parameters

* Parameter 1: Standard JsonArray type.
* Parameter 2: n. Returns the n-th data unit object in the array.

### Return Value

* The n-th data unit in parameter 1. The type may be JsonObject or JsonArray.

### Example

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
GetArrayItem(memberComponent, 1)
```

<Note>
  Example member component data:

  \[\{"label":"John (Employee ID 11)","key":"userid123"},\{"label":"Mary (Employee ID 22)","key":"userid124"}]
</Note>

### Returns

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
""
{"label":"John (Employee ID 11)","key":"userid123"}
```

Example:
