I’m working on processing multiple drafts based on a query but I am stuck on “TypeError: undefined is not an object” when referencing a list of drafts. I have tried to query a Workspace and query the Draft object.
I think query() has more than just the one mandatory parameter. Try updating that and check the count of objects in the array - and that an array is being returned.
sylumer is right, but the documentation does not make it clear how many of the parameters are mandatory. I think “filter” is mandatory and the ones from “omitTags” on are optional, but I’m not sure whether or not the “tags” parameter is required.
@sylumer@FireLarch Yes. Two parameters are required. I passed “inbox” for the filter and the query contained an array of objects. Thank you for your help!
None of the parameters for query are marked as optional. I have therefore always specified all of the parameters when using it.
Could the documentation be wrong? Yes, and given this started working, I assume there is some defaulting going on. If they are explicit, great. If they are implicit, then it is debatable and the parameters should not be considered optional.
The documentation may be incorrect for the query function, but I think the documentation is pretty clear for anything that is being marked as optional.
According to the documentation, sortDescending and sortFlaggedToTop defaults to false. It would seem that tags and omitTags defaults to [] and by providing a default value it is implicit that the parameters are optional.
I’ll take a look at the docs this week and clarify those parameters. You should have at least gotten a log entry in the Action Log indicating bad parameters, I believe.