Announcement

Collapse
No announcement yet.

Global variables not working as described.

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

  • Global variables not working as described.

    I'm trying to set and use a global variable, but it's not working.
    If I place:
    [pre]$myglobal = "Hello";
    sc_set_global($myglobal);
    [/pre]
    in onApplicationInit() or onScriptInit()
    and
    [pre]sc_alert([myglobal]);[/pre]
    in onRecord(), the value [myglobal] isn't available in onRecord(). When started, the application shows only a textbox labeled 'myglobal' to input a value.

    If I place:
    [myglobal] = "Hello";
    in onApplicationInit() or onScriptInit() with no other events defined, I get the same result when starting the application.

    I'm using a grid application to test this if it makes any difference.

    What am I missing?

  • #2
    Re: Global variables not working as described.

    Hello,

    Just a few tips, I rather work with [globalVariables] instead of using sc_set_global (but that is just me), and on your case I believe onApplicationInit() is the correct event.

    The reason why sc_alert it isn't working is because sc_alert doesn't work in onRecord().

    See the macro scope here.

    regards,
    Bernhard Bernsmann

    Comment


    • #3
      Re: Global variables not working as described.

      I used sc_alert() for simplicity. It works just fine with an explicit string like:
      [pre]sc_alert('Hello');[/pre]

      But whether or not sc_alert() will work in onRecord() isn't the real issue. I can't use:
      [pre][myglobal] = "Hello";[/pre]
      or
      [pre]$myglobal = "Hello";
      sc_set_global($myglobal);[/pre]
      to set a global variable.

      In the first case, the application starts by showing a textbox requesting a value for 'myglobal' regardless of the rest of the application's code. In the second case, the application starts with the value request if [myglobal] is used in any other code.

      Comment


      • #4
        Re: Global variables not working as described.

        Hello,

        That happens because you have to set the global variable value as "out(put)", meaning that the variable value will be set through code and not by the user.

        For more details, please visit: downloads.scriptcase.com.br/downloads/v6/manual/en_us/webhelp/manual_mp/12-Aplicacoes_de_Formularios/04-Aplicacao/06-Variaveis_de_Sessao.htm

        regards,
        Bernhard Bernsmann

        Comment


        • #5
          Hi Bartho,

          I use version 7, I got something that I put global variable in form, singe form and type is out
          [suppselect] = {supplierid};
          and then other form is editable view grid, I put code itemid_onChange
          $check_sql = "SELECT quoid, prid, supplierid, prdetailid, itemcode, "
          . "itemname, qtypr, uomid, currencyid, rate, unitprice "
          . " FROM lookup_prdet_quo "
          . " WHERE prid = '" . [pridselect]
          . "' AND supplierid = '" . [suppselect]
          . "' AND itemid = '" .{itemid} . "'";

          sc_lookup(rs, $check_sql);

          This global variable I use in grid as a link for select.

          And cannot show up as I want.
          I check with sc_ajax_message, the contains of [suppselect] is different.

          I use this code with version 6 is ok.
          Whats' wrong with version 7 ?

          Comment


          • #6
            Hello,

            Please contact our support regarding this issue. Our chat is active on workdays from 8:00am to 6:00pm (GMT -3), and our ticket system is always available.

            regards,
            Bernhard Bernsmann

            Comment


            • #7
              Hallo,
              please share on forum!!!
              Make sense to forum reality.
              I have the same problem with global variable that in 7.1 DOESN'T WORK...
              Thanks
              Andrea

              Comment

              Working...
              X