Prefilter record bug/issue

Hi,

I’ve got an issue that seems to me to be a bug. When creating a record selector module field, users can set a prefilter. This simplified SQL query should run on every interaction with the corresponding field, not just when the ‘Add record to module …’ page is loaded.

To give an example:

There are two basic modules: parent and child.
parent:
image

child:

The child module’s parentID field is a record selector to the parentID, setting the connection between the two tables.

I have two fields in my third module: a parentID record selector and a childID record selector. This child ID selector has a set prefilter record: parentID = ${record.values.parentID}

What I want to achieve is to choose a parentID and then choose a childID based on the previously selected parentID. I want to see only those childIDs that have the previously selected parentID.
Based on the tables I have provided above, if I chose parent p1, I want to see only c1 and c2 children when adding a new record.

I notice this query runs when loading the add new record page. The problem with this behavior is that no parentID is chosen at loading time. Thus, the parameter is undefined on the code level. See:
image

Note that if I choose a parentID then save the record with an empty childID, and then edit the existing record, the childID field is populated as expected; however, it is inconvenient to save and edit a record right away for this. See:


This prefilter query should be triggered whenever an element is selected from the parentID list, and then the options for the childID list should be reloaded.

I know this feature comes with an extra cost; however, manually choosing from a list of thousands of records is impossible.
If I’m wrong and this is the intended way of using the prefilter records, is there any way to solve my issue and achieve what I want?

Thank you for the help in advance.

Hello,

Did you try : parentID = ${recordID} ?

Hi @KOAMSK thanks for the quick reply; however, this doesn’t solve my issue in any way. And
I do not see how it could help me.
parentID = ${recordID} This gets triggered (query being sent to the server) when the page loads to create a NEW record. This means parentID = 0 is sent to the server which won’t do anything.

There are more ways in my head this ,could work, and I want to see if any of them is supported.

First: Trigger the query dynamically whenever I choose a parent (element) from the available parent list (references to the other table called Parent).

Second: Fetch all the children’s records and then sort them dynamically (when creating a new record) based on the currently chosen parentID reference.

Third: You might know a third way to solve this issue without modifying anything on the code. Do you know any solution? I’ve seen some previous topics here on the forum asking the same question and none of them got a proper working answer OR they might work and this topic is a bug report.

Indeed, I read your post too quickly. Sorry for that.
If I understood correctly, in the third module, you want to filter childID, when you change selecting parentID ?
I noticed that “Prefilter records” works on the values already saved. Which explains why it worked that way, in your case.

As far as I know, conditional fields are not supported yet. But they are planned next in the roadmaps.

Conditional fields
Set dependencies between fields

Indeed it should be reactive if the value changes, I’ll see if we can add this to the roadmap.
Currently you can probably achieve the same thing with conditional fields.
So that means hide the related selector until there is a value selected. So that the prefilter will have the correct value.

The conditional fields are accessible in the record block configuration.

Made an issue here

1 Like

Hi @KOAMSK and @jfortun,

thank you for your replies. I realized what you meant by using the conditional fields and achieved what I wanted. You need only one extra click to retrigger the query sent to the server. Users need to empty the parent selected to hide the child selector and then choosing another parent will result in a new query.

For future users, I used the record.values.parentID!=undefined conditional field.

1 Like