Category: JS Objects
Updated

This solution is summarized from an archived support forum post. This information may have changed. If you notice an error, please let us know in Discord.

Queryname.run() is not a function

Issue

I am trying to use a custom column with a computed value function that runs a query with a filter to calculate the total of selected rows. However, I am receiving an error that Queryname.run() is not a function. When I make the function asynchronous, the error disappears but the computed value is undefined. 

Similarly, when I try to pass parameters in an API query, I am receiving an error and following the instructions given in the documentation is not working. Switching from the forEach() method to a for loop resolves this issue.

Resolution

The user was facing an error while using a custom column in a Table with Computed Value as a function they had created in a JSObject. The function was running a query with a filter to get only selected rows and perform an action, then return the total. They were getting the error "Queryname.run() is not a function", but making the function async resulted in an undefined computed value.

The solution for this issue was to use the keyword this to access a function in the same file. So, this.FetchChildItems.data was a valid expression to use in the computation. Additionally, the issue with running a query from a JSObject was resolved by using a for loop instead of the forEach() method and passing the parameters correctly. After these changes were made, the issues were resolved.