Simplifier Developer Home Forums Simplifier Forum async, await, promise for server side connector call in process designer

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #20010
    AvatarKlaus79
    Participant
    • Topics: 30
    • Replies: 35
    • Jedi Master

    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?

    #20063
    AvatarKlaus79
    Participant
    • Topics: 30
    • Replies: 35
    • Jedi Master
    Up
    0
    Down

    nobody with an idea?

    #21765
    AvatarMalfurion
    Keymaster
      Has successfully completed the online course No-Code.
      Has successfully completed the online course Low-Code.
      Has successfully completed the online course Pro-Code.
    • Topics: 0
    • Replies: 94
    • Jedi Master
    Up
    0
    Down

    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);

    #23256
    AvatarKlaus79
    Participant
    • Topics: 30
    • Replies: 35
    • Jedi Master
    Up
    0
    Down

    Hi Malfurion,

    I’m calling a BO-Method1 with input1 . As a result I get inserted ID. Afterwards I’ve to call BO-Method2 with the inserted ID resulted from method1 and  the dataset which was input1 for method1.

     

    Best regards

    Klaus

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.