# PROC_UpdateFields

**Class** · Group: `Bulk DML`

<div class="apex-member apex-class">

```apex
global inherited sharing class PROC_UpdateFields implements IF_Async.Processable
```

**Implements:** [IF_Async.Processable](/reference/apex/if-async-processable)

**Known Derived Types:** [IF_Async.Processable.execute(List<Object>)](/reference/apex/if-async-processable#execute)

Processor for bulk field updates using the adaptive async framework. Implements IF_Async.Processable to enable automatic selection between Queueable and Batch execution. Supports the REPLACE, PREFIX, SUFFIX and COPY_FROM_FIELD update methods for flexible field value manipulation.

**Example**

```apex
PROC_UpdateFields.DTO_Parameters params = new PROC_UpdateFields.DTO_Parameters();
params.objectName = 'Account';
PROC_UpdateFields.DTO_Field field = new PROC_UpdateFields.DTO_Field();
field.name = 'Description';
field.value = 'Updated via bulk processor';
params.updateFields.add(field);
PROC_UpdateFields processor = new PROC_UpdateFields(params);
```

**See Also:** [IF_Async.Processable](/reference/apex/if-async-processable), [UTIL_AsynchronousJobLauncher](/reference/apex/util-asynchronousjoblauncher)

</div>

---

## Methods

| Method | Description |
|--------|-------------|
| global [IF_Queryable](/reference/apex/if-queryable) [buildQueryable](#buildqueryable)() | Builds a queryable for the configured object and fields. |
| global void [execute](#execute)([List](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_list.htm)<[Object](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_System_Object.htm)> items) | Applies the field updates to the given records and saves them. |

### buildQueryable

<div class="apex-member">

```apex
global IF_Queryable buildQueryable()
```

Builds a queryable for the configured object and fields.

**Returns** [IF_Queryable](/reference/apex/if-queryable) — An IF_Queryable instance for retrieving records to update.

**Example**

```apex
PROC_UpdateFields.DTO_Parameters params = new PROC_UpdateFields.DTO_Parameters();
params.objectName = 'Account';
PROC_UpdateFields.DTO_Field field = new PROC_UpdateFields.DTO_Field();
field.name = 'Name';
params.updateFields.add(field);
IF_Queryable query = new PROC_UpdateFields(params).buildQueryable();
```

</div>

### execute

<div class="apex-member">

```apex
global void execute(List<Object> items)
```

Applies the field updates to the given records and saves them. All updates are applied to each
record first, so two updates of one field build on each other. Then only the record's Id and the fields in the
update list are saved. Other fields on the record, such as the field a copy reads from, are not saved.

Because the save does not hold the field a copy reads from, the save does not check whether the user may read
that field. The read that found the records decides it. If the user's access to that field must count, read the
records with the user's access (user mode), as buildQueryable does by default.

**Parameters**

| Parameter | Type | Description |
|-----------|------|-------------|
| `items` | [List](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_list.htm) | The list of SObject records to update. |

**Example**

```apex
PROC_UpdateFields.DTO_Parameters params = new PROC_UpdateFields.DTO_Parameters();
PROC_UpdateFields.DTO_Field field = new PROC_UpdateFields.DTO_Field();
field.name = 'Name';
field.value = 'Updated';
params.updateFields.add(field);
List<Account> accounts = [SELECT Id, Name FROM Account LIMIT 100];
new PROC_UpdateFields(params).execute(accounts);
```

</div>

## Constructors

| Constructor | Description |
|-------------|-------------|
| global [PROC_UpdateFields](#constructors)([PROC_UpdateFields.DTO_Parameters](/reference/apex/proc-updatefields-dto-parameters) parameters) | Constructs a field update processor with the specified parameters. |

### PROC_UpdateFields(PROC_UpdateFields.DTO_Parameters parameters)

<div class="apex-member">

```apex
global PROC_UpdateFields(PROC_UpdateFields.DTO_Parameters parameters)
```

Constructs a field update processor with the specified parameters.

**Parameters**

| Parameter | Type | Description |
|-----------|------|-------------|
| `parameters` | [PROC_UpdateFields.DTO_Parameters](/reference/apex/proc-updatefields-dto-parameters) | The parameters defining which fields to update and how. |

**Example**

```apex
PROC_UpdateFields.DTO_Parameters params = new PROC_UpdateFields.DTO_Parameters();
params.objectName = 'Account';
PROC_UpdateFields processor = new PROC_UpdateFields(params);
```

</div>

## Inner Classes

| Class | Description |
|-------|-------------|
| [DTO_Field](/reference/apex/proc-updatefields-dto-field) | DTO representing a field to update on an SObject. |
| [DTO_Parameters](/reference/apex/proc-updatefields-dto-parameters) | DTO for parameters to query and update records. |
| [FieldUpdateMethod](/reference/apex/proc-updatefields-fieldupdatemethod) | Enum defining methods for updating SObject fields. |

---
