Can't insert a data in my collection from UI

Feature(s) impacted

Insert data

Observed behavior

Can’t insert data, I put an ID bu the UI tell me that I don’t put ID

Expected behavior

Data should be inserted

Failure Logs

When I check the request payload by inspecting element on my browser, effectively, the id is not pass

{data: {relationships: {category: {data: {type: "softwareCategoryV2s", id: "30948"}},…},…}}
data: {relationships: {category: {data: {type: "softwareCategoryV2s", id: "30948"}},…},…}
relationships: {category: {data: {type: "softwareCategoryV2s", id: "30948"}},…}
category: {data: {type: "softwareCategoryV2s", id: "30948"}}
product: {data: {type: "softwareProductV2s", id: "176079"}}
type: "softwareProductCategoriesV2s"

Context

Can’t insert a data in a collection

  • Project name: Uniseed
  • Team name: …
  • Environment name: …
  • Agent type & version: …
  • Recent changes made on your end if any: …

Hello @Charles_Touret,

Thanks for your message! :raised_hands:

The widget you’re are using here (called “belongsTo typeahead”) is working this way:

  • you type some characters
  • it loads a list of related records matching these characters
  • you pick the one you want by clicking on it

Meaning that: if you don’t pick one, none are selected.
Do you see what I mean?
If it’s not clear or if you think your problem is different, could you please share a little screencast with me?

Thanks a lot.

Yes I think you don’t understand the problem !
I know how it works and there is already a screen cast on the post haha, you can see that I well pick the two fields Category and Product via the UI, but the UI also ask me the id (I think it should not ask me the id field because it’s the primary Key and it is auto generated in my db), and when I input an ID, the UI tell me that id cannot be null, but I put an ID !

We can call I you want and I can share you my screen in live :slight_smile:

@Charles_Touret thanks for your answer.

I don’t see any screencast, only a screenshot, do you confirm?
I would need a video of your screen to understand exactly what you’re trying to do and what’s failing.

Thanks!

annnh ok ! I send you that in few minutes sorry ! :slight_smile:

@Charles_Touret any news? :slight_smile:

Sill same problem :confused:

the problem occurs when the collection contains two foreign key (join table)

On this screen it’s another collection but same problem

Hello @Charles_Touret,

Sorry for the delay and thanks for your answer.

Ok, now I think I understand your issue correctly.
Just one silly question: is it normal that you need to define the id of your new record in the UI? Shouldn’t it be defined by your server?

Anyway, I think I can reproduce your problem: if you create a record and specify only the id attribute (relationships excluded), then the id is not sent… But if you specify any other attribute, the id is sent.
I’m opening a bug report as of now, and I’ll let you know once it’s fixed.

Thanks again for the report and your patience :raised_hands:

Hey @adriguy , yes the id is supposed to be auto generated by my backend, the id is not mentioned in my collection code, but forest UI ask me to add one, and never send, I think you well understood the problem ! Let me know about it :confused:

The fix is being deployed.
Thanks for your patience @Charles_Touret

Have a good day !

How can we access the fix ? is there a package to update ?

@Charles_Touret if you don’t want to be asked to fill the id, would it be satisfying to set this field as read only (in its settings)?

The fix mentioned by @shohanr is available without any package to update.
Just refresh your browser and retry the creation: the given id should be sent within the payload!

Thanks.

It is still not working in my project you can see it there →

The behaviour should be insert into UserRole(roleId, userId) values (1,1);

@Charles_Touret,

In the case you are bringing up, you are not giving any id.
So it’s your backend/DB responsibility to attribute this id - it’s normal that you are not receiving the id from the frontend in your case!

What is your DB type? Did you define a sequence on the id attribute of this table?

This is not a problem with my db, this sql request is working → insert into UserRole(roleId, userId) values (1,1); and you can see that I don’t give the userRole.id in my request, it is auto generated

my db type is MYSQL,

I’m not sure I understand:

  • insert into UserRole(roleId, userId) values (1,1); is working fine on your DB?
  • But the request automatically created by your admin backend is not working? Can you check what is it exactly?

What’s sure is that your issue is not coming from the payload sent by the frontend anymore (it is not expected to send the id as you don’t provide it).

  • insert into UserRole(roleId, userId) values (1,1); is working fine on your DB?
    Yes this is working when I do the request manually in sql

I think I found what is not working from the UI,
→ When I put the field in read_only from the UI, the field is not send and I have a message telling me “you have to put a UserRole.id” and this sql request insert into UserRole(roleId, userId) values (1,1) is not done.

→ When I put the field id in editable from the UI, I can put an id, the field is sent and the request INSERT INTO UserRole (id,roleId,userId) VALUES(…) is done.

So I think there is still bug on the id autogeneration, or maybe there is something I can do in my model to autogenerate the id from the ui ?

Where do you have this message? In your admin backend console?
Can you see the request / SQL query that is generating this error?

Again, it’s not the UI job to give you the id in this configuration. Either your model or directly your DB should do it when missing.

I have this message in the UI ! and in the admin backend console I only have
"POST /forest/userRole?timezone=Europe%2FZurich 422 106 - 6.657 ms