Access value at path that may not exist
Hi everyone
I have a Query All Records function that is grouping records by a value (user.role) and then counting the number of records in each group. The output is shown below. I want to access the number of records for a particular role in a subsequent function. There is a chance that the role that I want to access the count for ('worker') may not exist though. How do I access the number shown with the arrow if it exists?
Thanks.
Best Answer
-
Yes,
If it is a list then you can make a loop through the list and check for a user_role - worker and if that condition is true then get the count value
Answers
-
Hi,
I think what you are looing for is "get" filter. it will allows you the get a value from a specific path and in case that path does not exists you can assign a value that should replace it, for example "null". This way you will not get the error that the path does not exists.
Hope that helps
-
Thanks @Pawel Magdanski. But I want to get the value at one path in an object if the object exists. In this case, I need to check if an object exists with user_role = 'worker' and if that object exists, get the value at path user_role_count in that object.
So perhaps its a two step process? First check if the object exists and then if it does, get the value at the path in the object?
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback