I’m currently working on integrating PowerApps with a PostgreSQL database but facing some issues when trying to insert records. The problem seems to be around the enums and how the data is being handled.
Database Structure:
I have a table named Order in PostgreSQL with the following structure:
Column Type Nullable Default
id integer not null nextval('Order_id_seq'::regclass)
title varchar(255)
status OrderStatus
fulfillmentStatus FulfillmentStatus
fulfillmentType FulfillmentTypes
docNumber text
date timestamp(3)
postedDate timestamp(3)
total double precision
createdAt timestamp(3) not null CURRENT_TIMESTAMP
updatedAt timestamp(3) not null
... (other fields)
Here, status, fulfillmentStatus, and other columns like paymentMethod, region are enums defined in PostgreSQL.
Enum Definitions (Example):
OrderStatus: [‘Pending’, ‘Confirmed’, ‘Shipped’, ‘Delivered’, ‘Cancelled’]
FulfillmentStatus: [‘Not Started’, ‘In Progress’, ‘Complete’]
The problem,
I am using PowerApps to insert a record into this table using the following Patch function:
Patch(
'public.Order',
Defaults('public.Order'),
{
title: "New Order",
status: "Confirmed", // Enum value
fulfillmentStatus: "Complete", // Enum value
date: DateValue("2024-09-23"),
total: 120.50
}
);
I am passing the status as a string (e.g., “Confirmed”), which matches the enum defined in the PostgreSQL table. However, I keep encountering errors related to type mismatch:
Error I am getting,
“The type of column ‘status’ doesn’t match the type of the column in the table.”
I tried the following,
I’ve confirmed that the values I’m passing for the enums match the exact strings defined in the database.
I’ve tried using different formats (quoted strings, escaped values) but no luck so far.
Tried escaping enum values (e.g., status: “”Confirmed””), but this also didn’t work.
The record-saving operation keeps failing with a “Network Error” or a “type mismatch” error.
Has anyone successfully inserted records into a PostgreSQL table with enums from PowerApps? Any guidance on how to properly handle enum fields in this context would be greatly appreciated. Is there a specific format or function that I might be missing when passing enum values from PowerApps?
Thanks in advance for any suggestions or tips!