Call the “press event” of a Button from a script element ?

  • Patrick
        3 years ago #24309

        Hello simplifier community,

        i got one question. If I create in the process designer a story with “subscribe” and listening to the “press event” of a Button, and then a connector is starting and doing some stuff, is it then possible to call this press from a script element ? I only know that it is possible to start the click event of an html button, smth. like this:

        document.getElementById(“buttonid”).click();

        But the problem is, that simplifier is not setting an onClickEvent to the button if you use the “press” in subscripe element. Is there any way to start the “PressEvent” in Javascript ? Something like this:

        SAPMBTN document.getElementById(“buttinid”).press();

        Best regards, Patrick

        Attachments:
        You must be logged in to view attached files.
        Jennifer Häfner
            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)
            Has successfully completed the online course Advanced (320)
            Has successfully completed the Intermediate Certification
            Has successfully completed the Advanced Certification
          3 years ago #24371
          Up
          4
          Down
          ::

          Hi Patrick,

          You can fire a button’s press event via script like this:

          sap.ui.getCore().byId(“yourButtonId”).firePress();

          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)
            3 years ago #24422
            Up
            1
            Down
            ::

            Hi Patrick,

             

            yes you’re right, OpenUI5’s ID scheme is always built up like this in the DOM: “ScreenId–WidgetId”. Therefore, if you’re using the byId function from the core element of OpenUI5 as in the above example, you have to prefix the id of the current screen you’re on inside of your application and then use two minuses as a separator from the widget id as well. However, there are more ways to access a certain screen element which don’t require you to prefix the screen id anymore:

            – From the screen object: sap.ui.getCore().byId(“ScreenId”).by(“WidgetId”)

            – Using “this” (important note: usually the “this” object that you can access from a script within the Process Designer of Simplifier will return the current screen’s controller; please keep in mind though that “this” might be something different depending on the scope during runtime, e.g. inside of a callback function): this.byId(“WidgetId”) or alternatively this.getView().byId(“WidgetId”)

             

            Hope this helps you to be a bit more flexible in accessing screen elements via script.

             

            Regards,

            Armin

            Patrick
                3 years ago #24425
                Up
                1
                Down
                ::

                Thanks a lot
                I have the following solution in use now. It runs perfect:

                Table: set enableBusyIndicator = false *
                Process Dashboard/Story/Connector: Show Busy Indicator = false *
                (*To prevent screen flickering on the smartphone after a standby.)

                DataWorkbench/Global Variables : interval (Any)

                onBeforeShow ->Script:
                var interval = setInterval(function(){
                sap.ui.getCore().byId(“Screen_main–Button_reload”).firePress();
                },300000);
                this.getGlobals().setVar(“interval”, interval);

                 

                onAfterHide -> Script:
                try{
                clearInterval(this.getGlobals().getVar(“interval”));
                }catch(err){
                console.log(err);
                }

                Patrick
                    3 years ago #24409
                    Up
                    0
                    Down
                    ::

                    Thank you very much. This has helped me a lot.
                    But only this works for me (your first version):

                    sap.ui.getCore().byId(“ScreenId–ButtonId”).firePress();

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

                  You must be logged in to reply to this topic.