> For the complete documentation index, see [llms.txt](https://docs.aiflo.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aiflo.app/web-workflow/add-or-update-record-stage.md).

# Add or Update Record Stage

The Add or Update Record stage allows you to either insert a new record or update an existing record in a selected repository. You can map each field with Custom, Calculated, Variable, or For Each Repository values, depending on the field type and context.

<figure><img src="/files/Etv3ZijI8f7HMenuhZpS" alt="" width="563"><figcaption></figcaption></figure>

#### Interface Overview

**1. Select Repository**

Choose the repository where the record should be added or updated.

**2. Identify Record (Only for Update) (Filter)**

If updating, select how to identify which record(s) to update — usually via a unique field (e.g., ID, Email) matched with a variable or For Each item.

**3. Fields Mapping**

Each field can be mapped using dropdowns:

| Component    | Description                                                                                  |
| ------------ | -------------------------------------------------------------------------------------------- |
| Select Field | Choose the field in the repository to add/update.                                            |
| Select Value | Choose how the field will be populated: Custom, Calculated, Variable, or For Each Repository |

#### Field Behaviour by Type

**A. Fields Supporting Custom, Variable, and For Each Repository**

Field Types:\
\- Single Line\
\- Multi Line\
\- Email\
\- Checkbox\
\- Lookup\
\- Multiselect\
\- Select\
\- Attachment\
\- User or Group\
\- Hyperlink\
\- Location

Behavior:\
\- Custom → Manual input (e.g., "Raaghav")

\- Variable

* An additional text field is shown to specify the variable as “${Variable:VariableName}”
* If the variable is of type record or records, use the format ${Variable:VariableName:FieldName} to access a specific field.

\
\- For Each Repository → Select from current item fields using {item.FieldName}

**B. Fields Supporting Custom, Calculated, Variable, and For Each Repository**

Field Types:\
\- Decimal\
\- Number\
\- Date

Behavior:\
\- Custom → Manual number or date input\
\- Calculated → Multiline expression editor (e.g., \<TODAY>\<PLUS>30)

\- Variable

* An additional text field is shown to specify the variable as “${Variable:VariableName}”
* If the variable is of type record or records, use the format ${Variable:VariableName:FieldName} to access a specific field.

\
\- For Each Repository → Dropdown of current loop item fields

#### Example – Simple Add or Update

| Field           | Select Value      | Result / RHS                          |
| --------------- | ----------------- | ------------------------------------- |
| Status          | Custom            | "Completed"                           |
| Interview Score | Variable          | ${Variable:InterviewScore}            |
| Date of Joining | Calculated        | \<TODAY>\<PLUS> 30                    |
| Education       | Variable (Record) | ${Variable:CandidateRecord:Education} |

### Under For Each Stage

Used when you need to add or update multiple records dynamically based on a list (loop).

**Add or Update Record Configuration (Inside For Each)**

| Step              | Description                                                              |
| ----------------- | ------------------------------------------------------------------------ |
| Select Repository | Choose where to add or update (e.g., Candidate)                          |
| Identify Record   | Match via Email, ID, etc.                                                |
| Field Mapping     | Define values using Custom, Variable, Calculated, or For Each Repository |

**Example:**

Loop through interview results in the **Candidate Interviews** repository.

* If the candidate exists in the **Candidate** repository → **update** their status and score.
* If the candidate doesn’t exist → **add** a new record with basic details.

**For Each Stage Configuration**

* **Repository to Iterate:** Candidate Interviews
* **Condition (Optional):** Status == "Completed"\
  → Only completed interviews are processed.

| Field Name         | Select Value        | RHS (Right-Hand Side)                   |
| ------------------ | ------------------- | --------------------------------------- |
| Candidate Name     | For Each Repository | Name                                    |
| Email              | For Each Repository | Email                                   |
| Interview Status   | Custom              | "Completed"                             |
| Interview Score    | For Each Repository | {Score}                                 |
| Updated On         | Calculated          | \<TODAY>\<PLUS>0                        |
| Assigned Recruiter | Variable            | ${Variable:Recruiter:AssignedRecruiter} |

### **Add or Update Record Under Condition Stage**

Scenario Goal

After a candidate interview is completed, you want to:

* Check if the Total Score is greater than or equal to 7.
* If true, either update the candidate’s record (if it exists), or add a new one in the Offer Letters repository.

**Condition Stage Configuration**

| Setting   | Value                    |
| --------- | ------------------------ |
| Variable  | Total Score              |
| Condition | Greater Than or Equal To |
| Value     | 7                        |

**Add or Update Record Configuration (Inside Condition – True Path)**

| Step              | Configuration                                       |
| ----------------- | --------------------------------------------------- |
| Select Repository | Offer Letters                                       |
| Identify Record   | Match via Email = ${Variable:Candidate\_Email}      |
| Field Mapping     | Define using Custom, Variable, or Calculated values |

**Field Mapping Example**

| Field Name     | Select Value      | RHS (Right-Hand Side)                   |
| -------------- | ----------------- | --------------------------------------- |
| Candidate Name | Variable          | ${Variable:Candidate\_Name}             |
| Email          | Variable          | ${Variable:Candidate\_Email}            |
| Offer Status   | Custom            | "Selected"                              |
| Joining Date   | Calculated        | \<TODAY>\<PLUS>30                       |
| Offered CTC    | Variable (record) | ${Variable:CandidateRecord:ExpectedCTC} |
