Advanced-CSBO-310 // Cannot read properties of undefined (reading ‘add’)

  • Andreas21
        4 months ago #47025

        Hello,

        I have defined the client-side business object as by the course.

        I can call the function “add” and I can call the function “multiplyBy10” fine and it works well (even though this was not part of the course).

        But when I call the function “mathCalculations”, then I receive the error-message in a popup:
        Cannot read properties of undefined (reading ‘add’)
        Find the details of the Console below.

        I used the source-code provided and copied it into the functions an defined the parameters according to the video. So this should normally work.

        Please help – I have spent ages to find the issue

        best regards
        Andreas

         

        Daniel
            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 months ago #47105
          Up
          1
          Down
          ::

          Good morning Andreas,

          the error you’re describing sounds like the dependency to the Math CBO is missing. Can you please edit the FeedbackApp CBO and check if the Math CBO was added?
          You can have a look at the video in Unit 6 Module 1 around 4:50 for better understandment.

          Let me know if that helped!

          Best regards and have a nice weekend,
          Daniel

          Armin Winkler
              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 months ago #52540
            Up
            1
            Down
            ::

            Hi Andreas,

             

            calling another function of the same client-side business object (CBO) from within the script of a CBO function is perfectly possible using the CBO API which is documented here: https://community.simplifier.io/doc/current-release/integrate/business-objects/create-client-side-business-object/client-side-business-object-api/. If you’ve just used a regular function invocation (i.e. something like ‘myFunction(myArguments)’) in your initial draft, it would only be possible to call local functions that are declared in the scope of the same CBO function script via that approach. However, to access other functions of a particular CBO, you need to invoke the API instead.

             

            Other than that your mental conception from other programming languages is 100 % valid and can also be applied to CBOs in Simplifier in the same way. I hope this clears up your confusion, please let us now in case there’s still questions left unanswered on your side.

             

            Kind regards,

             

            Armin

            • This reply was modified 4 months ago by Armin Winkler.
            Andreas
                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)
                Has successfully completed the online course Advanced (310)
              4 months ago #47545
              Up
              0
              Down
              ::

              Hi Daniel,
              that solved my issue, because I made the mistake and implemented the 3 functions (add, multiplyBy10 and mathCalculations) in the same CSBO called math instead of implementing the function matchCalculations in the CSBO FeedbackApp.

              Still I am struggling to understand, why it does not work.

              Why is it not possible, that a function “mathCalculation” defined in the CSBO “math” can call another function e.g. “add” which is defined in the same CSBO?

              Do I just make a mistake and have to call it differently? – or is this not possible in general, that 2 functions within the same CSBO call each other? Why is this? Does this have to do with the way how you have designed CSBO’s to work?

              Coming from other languages and thinking of an CSBO as an object which has some methods which can be called from “outside” e.g. the application, it is not possible that those methods call each other from within the CSBO.

              Thank you for shedding some light.

              Best regards
              Andreas

               

              Andreas
                  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)
                  Has successfully completed the online course Advanced (310)
                4 months ago #52578
                Up
                0
                Down
                ::

                Hi Armin,

                thanks a lot for your detailed explanation. This has answered all my questions.

                I did consult the API documentation prior to posting this question, but overlooked that there were 2 examples – one for calling a foreign CSBO and one for calling the same CSBO.

                Best regards
                Andreas

                • This reply was modified 4 months ago by Andreas.
              Viewing 5 posts - 1 through 5 (of 5 total)

              You must be logged in to reply to this topic.