Filtering collection field within script

In the Space: “SAP and Budgeting” I have two related databases: “Booking” and “Budget Category Line” (many-to-many).
To match bookings automatically to pre-configured budget categories, I need to update the entity collection field “Budget Category Lines” for the Booking where the script is ran on.

Running this without the filter works fine, but when running it as it is, it gives this error:

“Button” failed
executeSingleCommand: ‘Period start’ field was not found in ‘SAP and Budgeting/Budget Category Line’ database.
Originally, “Period start” and “Period until” were lookups from another relation of Budget Category Line, but that shouldn’t be the issue as I also tried it as a “formula lookup” and also direct date field.
The fields exist…

Here’s the relevant part:

const budgetCategoryLines = await fibery.executeSingleCommand({
“command”: “fibery.entity/query”,
“args”: {
“query”: {
“q/from”: “SAP and Budgeting/Budget Category Line”,
“q/select”: [“fibery/id”],
“q/where”: [
[“<=”, [‘Period start’], “$entityBuchungsdatum”],
[“>=”, [‘Period until’], “$entityBuchungsdatum”]
“q/limit”: “q/no-limit”
“params”: {
“$entityBuchungsdatum”: entityBuchungsdatum


You need to use the full name of the fields, e.g. 'SAP and Budgeting/Period start'

Oh thanks a lot, works!

I did use what I thought was the full name of the field, namely Database/Field (vs. Space/Field).
Thought the Space/DB notation was to define the field clearly for cases where the field name exists in multiple databases.
Now I’m wondering what the behavior is if I have the same field name in other Databases within the same space?

It won’t matter, because this
“q/from”: “SAP and Budgeting/Budget Category Line”
means that you will only be able to filter by fields that exist for that database, even if similarly named fields exist in other dbs in the same space.

1 Like