Update an object
Function: Update an object
This function allows you to modify an existing collection of information (an "object") by applying new values to it. Think of an object as a digital form or a record with various fields like "Name," "Email," or "Status." This action takes an existing object and updates or adds specific fields based on the new values you provide. It's particularly useful for updating data stored in your application, such as customer details, order statuses, or product information.
Input
- Existing object (Type: OBJECT)
The object you want to update. This could be a record from your built-in database (often accessed as
.payload), a temporary object you've created, or data received from an external system. This is the object that will be changed. - Overwriting values (Type: OBJECT) A collection of fields and their new values that you want to apply to the "Existing object." If a field in the "Overwriting values" already exists in the "Existing object," its value will be updated. If a field is new, it will be added to the "Existing object." This input is required.
Output
This function does not create a new object as an output. Instead, it directly modifies the "Existing object" you provided in the input. The updated "Existing object" will then be available for subsequent actions in your workflow.
Execution Flow
Real-Life Examples
Example 1: Updating a Customer's Contact Information
Imagine you have a customer record and need to update their email and add a new phone number.
- Inputs:
- Existing object:
\{
"customerID": "CUST001",
"name": "Jane Doe",
"email": "[email protected]"
\} - Overwriting values:
\{
"email": "[email protected]",
"phone": "555-123-4567"
\}
- Existing object:
- Result: The "Existing object" (Jane Doe's record) is updated. Her email is changed, and a new "phone" field is added.
Example 2: Changing the Status of an Order
You have an order that was "Pending" and now needs to be marked as "Shipped" with a tracking number.
- Inputs:
- Existing object:
\{
"orderID": "ORD789",
"product": "Laptop",
"status": "Pending",
"totalAmount": 1200
\} - Overwriting values:
\{
"status": "Shipped",
"trackingNumber": "TRK987654321"
\}
- Existing object:
- Result: The "Existing object" (the order record) is updated. Its "status" is changed to "Shipped," and a "trackingNumber" field is added.
Example 3: Adjusting Product Price and Availability
A product's price has changed, and it's temporarily out of stock.
- Inputs:
- Existing object:
\{
"productID": "PROD003",
"name": "Wireless Mouse",
"price": 25.99,
"inStock": true,
"category": "Electronics"
\} - Overwriting values:
\{
"price": 22.50,
"inStock": false
\}
- Existing object:
- Result: The "Existing object" (the product record) is updated. The "price" is changed to 22.50, and "inStock" is set to
false.