Interestingly, none of those onX-methods gets even called.
The query, importerRerunPost2, is a POST-request with Raw-JSON-payload and json response.
As said, when I submit the form I see always the correct response in the query-view. So the query is working properly.
It also has no caching or special optoins configured.
Welcome to the community @cwill-smg! Thanks for reaching out.
Based on what you've described, it sounds like you probably need to toggle on the setting shown below. You can find it in the JS query's Advanced settings.
By default, references to globally scoped variables are not updated during the execution of a single JS script. This is the default behavior for performance reasons, but explains why the query results seem to be out of sync.
This fix will hopefully address your issue, as well, @vhasabe! Let us know if either of you have any additional questions.
@Darren what you mentioned makes complete sense. I had raised this to Retool Support and they provided me a simple tweak to my code and it started to work for me.
let response = await getUserADData.trigger( {
additionalScope: {
uid : searchSelectRecipient.selectedItem.value
},
[// You can use the argument to get the data with the onSuccess function](https://docs.retool.com/queries/guides/javascript/#trigger-a-query)
onSuccess: function(**data**){
console.log("Success");
console.log("Attrs:", **data.attributes**);
},
onFailure: function(error) {
console.error("Error:", error);
// Handle the error here
}
});
In this case onSuccess is getting called consistently.
Glad to hear it, @vhasabe! Were you also able to solve this, @cwill-smg? If not, I'm happy to expand upon what I shared above or answer any additional questions!