async, await, promise for server side connector call in process designer

  • Klaus79
    Participant
      5 years, 1 month 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?

      Klaus79
      Participant
        5 years ago #20063
        Up
        0
        Down
        ::

        nobody with an idea?

        Mathieu Roll
        Keymaster
          Has successfully completed the online course Introduction
          Has 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, 11 months ago #21765
        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);

        Klaus79
        Participant
          4 years, 9 months ago #23256
          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.