function works directly - but when called from another function it throws an error
Okay - I am beating my head against the wall with this one. I have a function that with two inputs that runs correctly. But when I run that function from within another function - with the exact same two input values - it throws an error. I made a loom video - appreciate anyone guidance.
Comments
-
Hello, there
My guess is that this variable existing_master_email is not returning an integer, and then your conditional down below is passing through empty regardless of the conditional. Check your debugger to see what it is passing.If that is the case, try modifying the conditional using the expression below.
Let me know if that points you in the right direction.
-
so the conditional expression is definitely NOT the issue as that works fine - although I prefer your expression. I put the debug log in the copyPerson function at the very top - set to the master_person_id
when I run it - the debug logs show this:
which implies to me that there is NO VALUE set for the master_person_id - when I change the value to "1" instead of the variable - it runs - and the "data" value shows the "1". But I have put in a stop & debug that 100% confirms the variable = 1. So … I'm totally dumbfounded.
-
I managed to hack my way to success by changing the query all records to get a record. I did also change my if / then expressions to what you suggested - although I when did that first and it did not work - but then I changed the query all records to get a record - it works now. I don't understand why … but I am happy anyway :)
-
For others watching this thread - the issue was that the query all records was returning an array of "existing_master_email". Even though it only returned one record, it was still a "list". When using dot notation on the result to create lookup_id, one got
[3]
instead of3
. Passing that array to the field value of the get record call in the second function freaked it out, because it expected an integer (3) but got an array (3).
This situation happens all the time. When we see a weird result like that, look for:- square brackets near the value you're eyeballing. That could mean an array. If so, you might unwrap the array by fetching it's ".0" by dot notation:
lookup_id.0
. - Using query_all_records to get a single record. This needs to be unwrapped, or edit on the "output" panel and mark it as "single" rather than "list" to prevent the wrapping in the first place.
- square brackets near the value you're eyeballing. That could mean an array. If so, you might unwrap the array by fetching it's ".0" by dot notation:
-
Awesome, thanks Ray!
I knew this query was the culprit. 🙂
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