Best practice to pass/map variables to custom function
![Valentin R](https://us.v-cdn.net/6037124/user_avatars/4304535.jpg)
I'm sometimes dealing with situations when I have a few custom functions nested under each other. Let's say I get a user profile data (30+ key-value pairs) from db in the first one, but then I need to use these same keys-values in a custom function underneath. What would be the best practice to pass them to that function?
1. Pass just the db entry id and pull data from db again in sub-fuction? Seems wrong.
2. Add inputs for sub-function as a database link (quick and easy) and then map variables to from function 1 to function 2? (seems like this can only be done manually for each key-value)
3. Pass an object to function 2 and add a schema that is “table reference”? I did it but it still involves manual mapping of every field.
Answers
-
#3 — I found the way to map the data to the object, had to map it not the the object itself but to the sub-entity of it which has the scheme that is a table reference.. However, for some reason the object expects some “@meta” json as part of the object and I get this:
{"code":"ERROR_CODE_INPUT_ERROR","message":"Missing param: @meta","param":"contact.data.@meta"}
-
I often use the JSON type instead of the object so I don't have to write out all that schema. You get the same functionality, though with some fewer guardrails. I find the benefit in (dev) speed is worth it.
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