Navigation

    APPDRAG Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular

    REMINDER

    Please be respectful of all AppDragers! Keep it really civil so that we can make the AppDrag community of builders as embracing, positive and inspiring as possible.

    Before function call ... Execute custom javascript code

    General Discussion
    4
    9
    323
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Dick Honing
      Dick Honing last edited by

      is it possible to halt the execution of the cloud backend? For example, when a user presses the cancel button in an alert box which is invoked by pressing a button that will then trigger a cloud backend ...

      1 Reply Last reply Reply Quote 0
      • Daniel Mulroy
        Daniel Mulroy last edited by

        Great question @Dick-Honing!

        1 Reply Last reply Reply Quote 0
        • Wassim
          Wassim last edited by

          No you can't, and we are not able to do it.
          In micro-service architecture you're not supposed to cancel the execution of it.
          It has a timeout and you can still code inside some conditions that would stop a long loop, but you can't stop it from outside.

          1 Reply Last reply Reply Quote 0
          • Dick Honing
            Dick Honing last edited by

            in the meantime, I found a work-around. I've created a second 'Delete' button to which I attached a function that asks the user if it's OK or to cancel. If OK, I then call the (hidden) button to which the cloud backend action is linked, i.e. document.getElementById("delete").click();

            The downside is this approach, is that you've got to manually ad a id="delete" to the input field. If you ad an identification via PageBuilder, the id get's added to the surrounding element and then it doen not work.

            @Wassim long story short; is this a proper approach or it there a better/easier way?

            1 Reply Last reply Reply Quote 0
            • Wassim
              Wassim last edited by

              Hey @Dick-Honing I'm sorry but I don't get the whole situation to understand what you're trying to achieve.
              Can you send screenshots and give some more details?

              Dick Honing 1 Reply Last reply Reply Quote 0
              • Dick Honing
                Dick Honing @Wassim last edited by

                @Wassim the sitiuation is actually quite simple; I’ve got a button that is going to delete a record and before I wat to ask the user if he/she is sure about this. If OK delete or else cancel ...

                Dick Honing 1 Reply Last reply Reply Quote 0
                • Joseph Benguira
                  Joseph Benguira last edited by

                  Hey Dick,

                  when you configure your cloud backend action, check the checkbox "Execute custom javascript code"

                  9fad8051-0bc5-492f-9de2-b2979a155366-image.png

                  Then click on Edit code:

                  7bef3bf3-da89-4638-b495-039e6509fe41-image.png

                  There you can test if a condition is valid or not and return false to cancel the cloudbackend action before it starts!
                  If the condition is valid you can return true to continue the execution

                  1 Reply Last reply Reply Quote 2
                  • Wassim
                    Wassim last edited by

                    Oh ok I see! Yes, Joseph's solution is exactly what you need!

                    1 Reply Last reply Reply Quote 0
                    • Dick Honing
                      Dick Honing @Dick Honing last edited by

                      @Joseph-Benguira That's it 🙂 Thanks!

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post