async, await, promise for server side connector call in process designer
-
Klaus794 years ago #20010
How can I handle a server side connector with async/await?
I’ve tried with following coding to test if user and role exists so coding will be processed after that two checks.
var cbExistanceCheckRole = function(dataRoleExistance, optArg) {
if (!dataRoleExistance.result.output.exist === 0) {
message = message.concat(“Ungültige Rolle”, “<br />”);
dataCheck = false;
}};
var cbExistanceCheckUser = function(dataUserExistance, optArg) {
if (!dataUserExistance.result.id.length > 0) {
message = message & “Ungültige UserID” & “<br />”;
dataCheck = false;
}};
async function validateUser() {
var data_User = {};
data_User.CustID = custID;
data_User.Username = request_json.username;
await Screen.callConnectorCall(“User”, “getCustomerUser”, data_User, (async () => {
const result = await Promise.all([cbExistanceCheckUser(data, optArg)]);})(), true, true, null);
}async function validateRole() {
var data_Role = {};
data_Role.custID = custID;
data_Role.role = request_json.role;
await Screen.callConnectorCall(“Role”, “checkRoleForRoleCatalog”, data_Role, (async () => {
const result = await Promise.all([cbExistanceCheckRole(data, optArg)]);})(), true, true, null);
}
debugger;
(async () => {
const result = await Promise.all([validateUser(), validateRole()]);})();
Theoretically it is working, but I do not get result data from connector call “getCustomerUser” or “checkRoleForRoleCatalog” in callback functions “cbExistanceCheckRole” or “cbExistanceCheckUser”.
Any ideas on that?
Mathieu RollHas successfully completed the online course IntroductionHas successfully completed the online course Intermediate (200)Has successfully completed the online course Advanced (300)Has successfully completed the online course Basics (100)4 years ago #21765::Hello Klaus,
I do not understand what you are trying to achieve.
A Simplifier Connector Call is always Async.
So with the following code the fnSuccess will be called async.
var fnSuccess = function(data) {
console.log(data);
};var fnError = function(error) {
console.log(error);
};this.callConnectorCall(“Example_Connector”, “Example_Call”, {}, fnSuccess, false, true, fnError);
You must be logged in to reply to this topic.