Hi!
I'm facing some troubles saving an Output parameter to my DataBase, I really think I'm doing this in the right way. Can anyone help me with this? Te Output parameter that I'm trying to save is CardHash as shown below. The alert shows me that the JS code its working well, but when I try to save in my DB the Output CardHash is always null. This is the flow:
Bst Regards!
Hi Bruno,
Since I never tried it before, I tried at my end and I am able to save the output parameter returned by JS successfully in the DB using an OnClick event of a button. Just wanted to check on which event are you trying to save the data? If it is possible, Can you please share you oml here so that I can have look.
Thanks,
Sachin
Hi Sachin Mahawar! Thanks for your answer
Sorry, I can't share the oml, I'm working in a company that don't allow me to share, because the data have some sensitive data.
You told me that you're using OnClick Event. I'm using the same event, and the Output Parameter data type is text.
Bst Regards!!
You seem to be using async callbacks for your success and error scenarios (you provide actions that will be called once there's an outcome). This means that if you leave your code as is, by the time your JavaScript call to checkout.getCardHash() finishes, most likely your success callback hasn't run yet (and so... no value was assigned to the CardHash output parameter).
Please read this documentation on how to signal the end of an async call in OutSystems (and familiarize yourself with the concept of promises in JavaScript).
TL;DR version of it: You should probably add a $resolve(); instruction right after the output parameter assignment (assuming the alert() is just for debugging purposes) for both the success and error callbacks.
Hope this helps!