Announcement

Collapse
No announcement yet.

Custom Filter on Button click

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Custom Filter on Button click

    How can i tell SC to change the filter on a form when a button is click?

    What i am facing now, it prompt a blank 'OK' button page, and nothing is filter.
    I would like to get ride of the button goto a different form.
    What i expect is simple, the page return 5 rows now (based on initial filter), then when the new button click, it return 3 rows (based on another filter logic)


    Thanks for the guidance.

  • #2
    There are several options, but you can use a global variable to change the where clause or use sc_macro's. At the end of your script of the button do a sc_exit(sel);

    It will prevent the ok button and restart your application.
    Albert Drent
    aducom software netherlands
    scriptcase partner, reseller, support and (turn-key) development
    www.scriptcase.eu / www.scriptcase.nl

    Comment


    • #3
      Originally posted by aducom View Post
      There are several options, but you can use a global variable to change the where clause or use sc_macro's. At the end of your script of the button do a sc_exit(sel);

      It will prevent the ok button and restart your application.
      hi Albert, thanks it worked.
      But how to manipulate the filter? alter the result return in a form on a custom PHP button click?

      i tried to execute following code in my PHP button
      {sc_where_filter} = "";
      sc_exit(sel);
      what i expect was to return all result, end up there is no different/chances occurred.
      Last edited by weilies; 10-18-2014, 12:00 PM.

      Comment


      • #4
        No that won't work as your application will startup again, all fields willl be initialized. So you can set a global variable and fill that with the initial filter in the onapplicationinit or (that's how I often do it) set it in the onexecute event of the menu calling the application. Then in the onclick event you change the global variable and start the application. Be aware that onscriptinit is fired too, so don't set your global there.
        Albert Drent
        aducom software netherlands
        scriptcase partner, reseller, support and (turn-key) development
        www.scriptcase.eu / www.scriptcase.nl

        Comment


        • #5
          i am quite concern to set a global. Is there any App level scope?
          coz if my global var set as [sqlFilter] and will it impacts if i have another app with same global var name?

          also, what's the macro to change button lable?
          Last edited by weilies; 10-18-2014, 09:52 PM.

          Comment


          • #6
            I understand your conceirn, but we do it that way. In fact we declare all globals in the logon procedure so that we don't make a mess elsewhere. We don't like the idea of creating them 'somewhere' in the application. If you call an app using it you can get obscure errors like 'global xxx not found'. Even if you are using plain php you will run into similar issues, you can set scope but it needs to be bound to a session to be able to retrieve.

            I don't know of any macro to change the button label.
            Albert Drent
            aducom software netherlands
            scriptcase partner, reseller, support and (turn-key) development
            www.scriptcase.eu / www.scriptcase.nl

            Comment


            • #7
              can u show me how to declare them during logon procedure?
              I am not quite understand.

              Comment


              • #8
                Originally posted by weilies View Post
                can u show me how to declare them during logon procedure?
                I am not quite understand.
                All global variables we use are not declared in the application where they are first used, i.e. as in or out, but we declare them in our logon application. As this is our first application that start, after successful login (onvalidate) we declare all our global variables and initialize them if necessary. If you don't have a logon application you can consider doing it in the main application, the first that is fired to start your application. It's standard SC method:

                [glob_patid]=0;
                [glob... etc.
                Albert Drent
                aducom software netherlands
                scriptcase partner, reseller, support and (turn-key) development
                www.scriptcase.eu / www.scriptcase.nl

                Comment


                • #9
                  weilies,

                  An alternate approach you may want to consider, that I use. Instead of globals, I establish session variables "dedicated" to a particular app. for instance:

                  $_SESSION['my_app']['retry_count'] = 10;

                  This way, I am "manually" enforcing scope, and feel a little less fear that it will be used accidently somewhere that it shouldn't.

                  It is not necessarily more or less safe than Albert's approach, the most important thing is to choose an approach and stick to it.

                  Dave
                  Dave Prue
                  Code Whisperer
                  Lahar International Corp
                  www.lahar.net

                  Comment

                  Working...
                  X