Server Action Database Insert - Unable Set Value for Primary Key in Table

Hi.
I haven’t seen this before, or probably didn’t bother with it.
I am trying to add a new insert database step in server action. In the insert options, when I select the table, I can see all the columns, except the ID (primary key) column.
When I add it using the + button, it does get added to the list.

image

But, then I cannot edit the value of this column.
I have complete control over the ID and there will be no duplication etc.
How can I set this column’s value so that new entry is inserted in the DB with that value?

Generally your primary key should be set to auto increment in your database.

1 Like

Yes, you cannot insert into a key auto increment field, the value is inserted automatically by the database insert action.

1 Like

In addition to the two replies above mine - If you need to store some custom information in a database field, add it to your table as a regular field (not a primary key!).

1 Like

Appreciate all the input. The general practice is definitely to use auto-increment and forget about the field when inserting rows. I usually keep it that way too.

But Wappler should give this flexibility in my opinion.
The field I am using is not auto-increment, just a primary key.
And SQL itself does not have any rule that primary keys need to be AI or primary keys cannot be set in an insert query.

It should still be available in the field picker if needed

image

Yes it is. I have already done that. But as you will see, you cannot set the value for this field, even after selecting.

Also, I tried setting the value in JSON directly, but I ran into some other issue in the server action… so could not test it out.

Now I am confused what you mean?

This is not working for me. :flushed:
I cannot edit the value part. It does not change to edit mode… nor does it show the action picker icon/panel.

I can only assume this is some issue with the field definition, how exactly is that field defined

1 Like

The field was a primary key.

I have now updated the table to have a separate auto-incrementing column as I was losing time on this.