Announcement

Collapse
No announcement yet.

New button to change SQL in realtime

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

  • New button to change SQL in realtime

    I have a form app with button 'Show Latest' (as attached pic),
    how could i show only LATEST row (only display 1 row) instead of all?
    Attached Files

  • #2
    i found this macro
    http://www.scriptcase.net/docs/en_us...c_where_filter

    but stated it only work for 'GRID' app.
    hope someone could enlighten me coz it's one of the critical function i need to create my app.

    Comment


    • #3
      hi,

      did you try using SQL LIMIT 1?

      Comment


      • #4
        hi, i think you misunderstood my question

        as you can see, i have a field 'address type', i could have 5 HOME addresses, 2 OFFICE addresses, they are all having different effective date.
        i would like 'Show Latest' clicked, it reflect latest home address and latest office address.
        So, using SQL LIMIT 1 will not work coz it doesn't work since it hardcoded to only return 1 row.

        What i am looking for, is a method to change "Where clause" definition in form app when the button clicked

        Thanks for your help but it jz does't resolve my issue :s

        Comment


        • #5
          Yes, it is the same, in button itself you have to put some code or java code, which i'm not aware of it but the idea of LIMIT 1 should be also useful as you can limit those displayed record to 1 only when displayed, which is AFAIU is what want to do

          I guess many guys here can help in this, i am not that advanced actually, just trying small small


          Mike

          Comment


          • #6
            Hi mike, I am glad you have been actively help. I am sure ideally it should work IF sc have provide such API or macro, which I comb through and yet can't find the suitable code.

            I am also hoping some senior can guide me how to achieve it coz it look very basic and yet I couldn't figure out in sc way

            Comment


            • #7
              yes, and your way seems interesting, please let us know if you could success for sharing info sake

              good luck

              Comment


              • #8
                dear gurus,

                i have been stuck here for more than 24 hours
                anyone can give a helping hand?

                Thank you

                Comment


                • #9
                  Hi,
                  I suggest you use two buttons: 'Show all' and 'Show latest' to be able to switch back and forth.

                  In SQL -> Where Condition: [glo_where] //global variable that contains your where clause.

                  In onScriptIni:
                  if(!isset([glo_where])) //to make sure we have a valid where clause
                  {
                  [glo_where] = '1 = 1';
                  }

                  Code for 'Show latest' button:
                  [glo_where] = "the where clause to show the latest addresses";
                  sc_redir(hcm_person_address,glo_where=[glo_where],'_self'); //call the form itself with the new where clause

                  Code for 'Show all' button:
                  [glo_where] = "1 = 1";
                  sc_redir(hcm_person_address,glo_where=[glo_where],'_self');

                  In the onLoad event you can hide and show the correct button depending on your [glo_where] variable.


                  Hope this helps.
                  jsb

                  Comment


                  • #10
                    Originally posted by jsbinca View Post
                    Hi,
                    I suggest you use two buttons: 'Show all' and 'Show latest' to be able to switch back and forth.

                    In SQL -> Where Condition: [glo_where] //global variable that contains your where clause.

                    In onScriptIni:
                    if(!isset([glo_where])) //to make sure we have a valid where clause
                    {
                    [glo_where] = '1 = 1';
                    }

                    Code for 'Show latest' button:
                    [glo_where] = "the where clause to show the latest addresses";
                    sc_redir(hcm_person_address,glo_where=[glo_where],'_self'); //call the form itself with the new where clause

                    Code for 'Show all' button:
                    [glo_where] = "1 = 1";
                    sc_redir(hcm_person_address,glo_where=[glo_where],'_self');

                    In the onLoad event you can hide and show the correct button depending on your [glo_where] variable.


                    Hope this helps.
                    jsb
                    Hi jsb, i believe your code could work. Let me try later
                    Will your code work if my address app is use as 'child app'?

                    I hope SC developer can hear my voice, there should be a feature allow button to manipulate the GRID/Form

                    Comment


                    • #11
                      How would SC redirect if the redirection code is trigger from child app INSIDE a master app?
                      will it refresh the child app section? or even the master app will refresh as well?

                      If master app redirect, it would not be correct behavior i want

                      Comment


                      • #12
                        It doesn't show expected result after configured as per jsb said
                        https://docs.google.com/document/d/1...it?usp=sharing

                        Comment


                        • #13
                          Originally posted by weilies View Post
                          It doesn't show expected result after configured as per jsb said
                          https://docs.google.com/document/d/1...it?usp=sharing
                          That's expected behaviour. Just click on button.
                          Scriptcase wants a value for your global variable [glo_where] which hasn't been set yet.
                          That's what the if-structure in onScriptInit is for.

                          I suggest you get the functionality of the form you want/need working and then do the next step and include it
                          in a master/detail scenario. And no, it will not redirect your master. :-)

                          jsb
                          Last edited by jsbinca; 07-22-2014, 05:52 PM.

                          Comment


                          • #14
                            Hello,

                            I will discuss your suggestion with our team.

                            regards,
                            Bernhard Bernsmann

                            Comment


                            • #15
                              Originally posted by bartho View Post
                              Hello,

                              I will discuss your suggestion with our team.

                              regards,
                              Bernhard Bernsmann
                              Hi Bernhard, thanks for the consideration. hope you can let us know when will it be out (if possible)
                              i manage to make it work with jsb's suggestion, THANKS!

                              But to create a large scale app, i design my app to have multiple master-detail (with the show all/latest feature), so lots of customization needed
                              If SC deliver such macro to cater for form app, it save lots of time & coding

                              Comment

                              Working...
                              X