execute connector call based on a string

  • Klaus79
        4 years ago #20029

        Normally in business object a connector can be called like this:

        result = Simplifier.Connector.xyz.connectorMethod([{‘param1’: input.input1, param2: input.input2}]);

        But how can I achieve it to call the connector dynamically.

        Adopted that I get the connector name dynamically in business object: var connector = “xyz”;

        I tried with eval() but this does not work and results in  <TypeError: null has no such function \”connectorMethod\”>

        connectorExecString = ‘Simplifier.Connector.’ + connector + ‘.connectorMethod([{\’param1\’: ‘ + input.input1 + ‘, \’param2\’: ‘ + input.input2 + ‘}])’;
        result = eval(connectorExecString);

        by the way: connectorExecString is build correctly in my opinion:

        Simplifier.Connector.xyz.connectorMethod([{‘param1’: input.input1, ‘param2’: input.input2}]);

         

        Mathieu Roll
            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 ago #20030
          Up
          0
          Down
          ::

          Hello Klaus,

           

          Simplifier.Connector is a javascript object so you can use the standard javascript object notation to achieve it.

          For example:

          var myConnectorName = ‘Test_Con’

          Simplifier.Connector[myConnectorName].testCall()

        Viewing 2 posts - 1 through 2 (of 2 total)

        You must be logged in to reply to this topic.