Issue with Creating a Relationship in the Click Event

I’m encountering an issue while adding a relationship to the Componentes table in the click event. Here’s what I’m trying to do:

  • I’m creating a relationship object to add properties and establish the relationship with the Componentes table.
  • However, I’m getting an error that expects an array of objects instead of a single object.

My goal: I want the relationship to accept a single object, not an array of objects.
image
Additionally, in selectcomp, I only have the id of the Componentes.
Could you please guide me on how to modify my code or configure the relationship to work with a single object?

Hi @ALA

The Bulk Create creates objects from the passed list (objects), if you need to create only one use Save Object block

and then pass it to create relations.
I do not remember if it’s possible to connect to “children” only one object if not you can add a Create List (with single item) between the create relation and save object blocks

Regards,
Vlad


When I use the getProperty method to retrieve citynames, it works perfectly when citynames is defined as a block.
However, when I try to retrieve it through a form using an input field, it doesn’t work as expected.

Could you help me identify the source of the problem or let me know if any special configuration is required in this case?

In the first case, you retrieve cityNames from the PageData but in the second one you just connect the entire FormData, I believe this is the issue

Thank you for your response.

Yes, I understand that the issue might be related to passing the entire FormData. However, I am encountering the following error:

Error: Objects must be provided and must be an array of objects.

Could you please clarify how I can correctly structure and pass the FormData to avoid this error?

Hello @ALA,

You can use the Print block for debugging, for instance, like this:

This way, in the developer console, you can compare the data you are passing for creating relations and adjust them to the correct format.

If the form is intended for creating multiple objects, you will need to retrieve their values, create objects that will be saved to the table, and add them to an array, which you will pass to the Bulk Create block. This is because it accepts an array, as indicated by the error you are encountering.

For example, like this:

Regards,
Alexander

Hi Alexander,

Thank you for the clarification and the examples provided.

I followed the same steps you outlined, but I am now encountering a different error:

Child Id must be provided and must be a string or number.

Could you please advise on how to resolve this issue? Am I missing something in the configuration of the objects or the way data is being passed?

I apologize, this is my mistake. Bulk create already returns an array. Could you please try removing this block and try again:

I also wanted to clarify that when you create an object, propName should be the name of the column in the table where you are creating the record.

Regards,
Alexander

1 Like

Hi Alexander,

Your solution worked perfectly. Thank you for your guidance and support!

Best regards,

1 Like