Can someone confirm this is the right way to trigger a Confirmation popup in the SDK?
The popup itself works fine but I realized that, whenever the 10sec time out is triggered, the function that should happen when the user clicks on “Create” (createFct()) is triggered as well.
function confirmCreation(
a,
paramxyz
) {
if (paramxyz === "") {
notify("warning", "Fill out all required fields.");
return;
}
client.interface
.trigger("showConfirm", {
title: "Please confirm",
message: `Are you sure?`
})
.then(function(result) {
if (result = "Save") {
createFct(
a,
paramxyz
);
}
})
.catch(function(error) {
console.log(error);
notify("error", `Confirmation failed. Contact support: "${error.response}".`);
});
}
This is in fact the correct way to use it. then will always get triggered if there are no errors.
client.interface
.trigger("showConfirm", {
title: "Please confirm",
message: `Are you sure?`
})
.then(function(result) {
/** result.message would return either "OK" or "Cancel" or "Request timed out" based on user input. You should check it in the next line **/
if (result.message === "OK") { // This is correct.
createFct(
a,
paramxyz
);
}
})
Hey, Sorry I could not reproduce this. Chrome DevTools generally prints the console log at a particular time. But when you extend it, it shows you the latest value. As long as you check result.message for a particular case, it should be fine. Please check the code above for reference.