Forum Discussion
JohnBarulich1
7 years agoQrew Cadet
Thanks for the reply as usual Dan,
One thing I'm curious about is the conceptual difference between your code and mine. My $.get() call does return a promise. Your code also returns a promise. Both code snippets, yours and mine, wait for the request to finish before proceeding. What's the subtlety here that I am missing?
Edit: Also, no need to worry about getPerm(), it doesn't influence this code, I should've just left it out.
Edit: From further analysis, it seems that your code is conceptually equivalent. I get no error from the API call, but no records are processed into the xml. I ensured the link to the table is correct. It works successfully if I query the same field but with different constraints (i.e. {'66'.EX.'0'} , also no query parameter). getPerm() returns $.ajaxSetup call. I turned async off for debugging but still, no response. I think it has to deal with QuickBase's back end implementation of the "{66.IR.'last wk'}".
Thanks
One thing I'm curious about is the conceptual difference between your code and mine. My $.get() call does return a promise. Your code also returns a promise. Both code snippets, yours and mine, wait for the request to finish before proceeding. What's the subtlety here that I am missing?
Edit: Also, no need to worry about getPerm(), it doesn't influence this code, I should've just left it out.
Edit: From further analysis, it seems that your code is conceptually equivalent. I get no error from the API call, but no records are processed into the xml. I ensured the link to the table is correct. It works successfully if I query the same field but with different constraints (i.e. {'66'.EX.'0'} , also no query parameter). getPerm() returns $.ajaxSetup call. I turned async off for debugging but still, no response. I think it has to deal with QuickBase's back end implementation of the "{66.IR.'last wk'}".
Thanks
- _anomDiebolt_7 years agoQrew Elite>My $.get() call does return a promise.
That is true but the function getAndSetList() does not return a promise (it can't because there is no return statement). - JohnBarulich17 years agoQrew CadetgetAndSetList() does not return a promise because the promise happens within the function after the $.get() call. Your code snippet also conceptually waits to process the xml as well, just outside of the function. Both your code, or mine, do not work for some reason.
Why? - _anomDiebolt_7 years agoQrew EliteUnless getAndSetList() returns a promise it will run to completion and return undefined before the promise within it has a chance to resolve. Once getAndSetList() returns it looses scope and the promise within it is lost.
- JohnBarulich17 years agoQrew CadetThere has to be something I do not quite understand. How can my function return prior to the code being executed, when we are guaranteed by the promise to wait until the request is completed before execution can continue. The code within the function does not complete until that promise is fulfilled, so how does the function return prior to this?
I did test your solution but it returns the same result. Yet I can query all records with a specific field. Are we totally sure the backend implementation is correct? - JohnBarulich17 years agoQrew Cadet
function getAndSetList() {
}
var url = "blahblah";
getPerm();
$.get(url, {
act: "API_DoQuery",
query: "{66.IR.'last wk'}",
clist: "66"
}).then(function(xml){
console.dirxml(xml);
}); /* console.log("Hi"); */
with the addition of the console.log("Hi"), I now see what you are saying. It treats the whole promise block as asynchronous as well, no?
But your solution does not work. Why? Can you test the IR.'last wk' on one of your tables as well and test? - UrsulaLl7 years agoQrew Assistant CaptainTo add to the above comment, run the search as a URL, make sure that the search parameters match your do_query, it may be as simple as a missing space or quotation mark. If it returns empty or with an error, then something else is going on...
http://target_domain/db/target_dbid?a=API_DoQuery&query={66.IR.'last
wk'}
I have had issues in the past with duration fields, so it may be that the script is working as intended, but that field is being tempermental.
- JohnBarulich17 years agoQrew CadetI figured out what my issue was. From the documentation:
"All records where the date or date/time in fid 7 occurs within the 7-day period...XML example:
<query>{7.IR.'last wk'}</query>"
the FID is supposed to be the DATE field, and obviously can't be anything else but the DATE field. Of course you can add on subsequent fields with the 'clist' parameter