Ask AI
Skip to main content

Update a data record

Function: Update a data record

This function allows you to modify an existing record within your application's built-in database. It's crucial to remember that this action is specifically designed for existing data. If you need to add a brand new record, you should use the "Create data record" function instead. This function will not work with new data records.

Input

  • Data (DATA): This is the specific data record you want to change. You must provide an existing record from your database. The platform will use the unique identifier of this record to locate and update it. This input is required.
  • Async (BOOLEAN, default: false): This setting determines how the update operation is performed.
    • If set to True, the update will happen in the background, allowing your application to continue with other tasks immediately. You won't wait for the update to complete.
    • If set to False (the default), the application will wait for the update to finish before proceeding. This ensures the data is updated before any subsequent actions.

Output

No direct output is returned by this function. Its primary purpose is to modify the specified data record in your database. If the update is successful, the record will be changed. If an error occurs, an error message will be displayed.

Execution Flow

Real-Life Examples

  1. Updating a Customer's Email Address (Synchronous):

    • Scenario: A customer updates their email address on their profile page. You want to ensure the database reflects this change immediately before sending a confirmation email.
    • Inputs:
      • Data: An existing Customer record (e.g., Customer ID: CUST001) with its Email field updated to "new.email@example.com".
      • Async: False
    • Result: The Customer record with ID CUST001 in the database is immediately updated with the new email address. The application then proceeds, knowing the update is complete.
  2. Adjusting Product Stock Levels (Asynchronous):

    • Scenario: An inventory system processes a large shipment, and you need to update the stock quantity for a Product record. This is a background task that doesn't need to block the user interface.
    • Inputs:
      • Data: An existing Product record (e.g., Product ID: PROD123) with its Stock Quantity field updated from 50 to 150.
      • Async: True
    • Result: The Product record's stock quantity is updated in the database. The application continues processing other tasks without waiting for this specific stock update to finalize, as it happens in the background.
  3. Correcting a Task Status (Synchronous, with potential error handling):

    • Scenario: A project manager marks a Task as "Completed". However, they accidentally try to update a task that was already deleted.
    • Inputs:
      • Data: An existing Task record (e.g., Task ID: TASK456) with its Status field updated to "Completed". (In this example, let's assume Task ID TASK456 does not exist in the database).
      • Async: False
    • Result: The system attempts to find and update Task ID TASK456. Since the task does not exist, an error message is displayed to the user, indicating that the record could not be found and therefore not updated.