Announcement

Collapse
No announcement yet.

[SOLVED] Capture old variables on Before update

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

  • [SOLVED] Capture old variables on Before update

    Hello,

    I would like on a form to capture old value and new value of a field record.
    The field is {race}

    OnBeforeUpdate, i put these lines:
    $old_race = {race};
    sc_set_global($old_race);

    OnAfterUpdate, i send by mail this line:
    $mail_message = 'Type d\'articles '.{PRODUCTION}.' Ancienne race '.{old_race}.' Nouvelle race: '.{race}; // Message body

    But it's return always the new value of {race}:
    Type d'articles Articles muscles congelÚs avec maturation Sta lAncienne race MAINE ANJOU Nouvelle race: MAINE ANJOU

    I was waiting for:
    Type d'articles Articles muscles congelÚs avec maturation Sta lAncienne race CHAROLAIS Nouvelle race: MAINE ANJOU


    Could you help me?
    Best regards,
    Olivier

  • #2
    In the onbeforeupdate the new value is already there in the field which you refer to. To retrieve the old data you need to use the onload event. This event is triggered whenever a new record is selected. If you save your data into a global here it will be available in the onbefore- and onafterupdate.
    Last edited by aducom; 10-01-2013, 05:58 PM.
    Albert Drent
    aducom software netherlands
    scriptcase partner, reseller, support and (turn-key) development
    www.scriptcase.eu / www.scriptcase.nl

    Comment


    • #3
      Form ... onRecord ...?
      Best regards: - Reinhard -

      I use ScriptCase 8 Enterprise Edition, Version 8.(latest)

      Comment


      • #4
        No, you're right, I meant the onload.
        Albert Drent
        aducom software netherlands
        scriptcase partner, reseller, support and (turn-key) development
        www.scriptcase.eu / www.scriptcase.nl

        Comment


        • #5
          Hello,

          Thanks for help.
          I tri do save the tghe old value in a data, but i can't exploit it then:
          Onload, i put these lines:
          $old_race = {race};
          sc_set_global($old_race);


          OnAfterUpdate, i send by mail this line:
          $mail_message = 'Type d\'articles '.{PRODUCTION}.' Ancienne race '.{old_race}.' Nouvelle race: '.{race}; // Message body

          But i have this message when i validate:

          Erreur

          Undefined variable: old_race

          What's means?

          I try to use old_race with [] in OnAfterUpdate, but same message.

          Best regards,
          Olivier

          bUT I HAVE THIS MESSAGE/

          Comment


          • #6
            sc_set_global($old_race) => [old_race] not {old_race} ...

            Btw, in the documentation for sc_set_global():
            NOTE: This macro will be discontinued soon. You should use the method of creating global variables ??using brackets. Ex: [var_glo_user] = "test";
            Best regards: - Reinhard -

            I use ScriptCase 8 Enterprise Edition, Version 8.(latest)

            Comment


            • #7
              Hello,
              It's OK now, I use correctly variables.
              Thanks for you help!

              Olivier

              Comment


              • #8
                Hello,
                I've a little problem:
                my code is the following:
                onload:
                $old_race = {race};
                sc_set_global($old_race);

                OnAfterUpdate:
                $mail_message = 'Type d\'articles '.{PRODUCTION}.' Ancienne race '.[old_race].' Nouvelle race: '.{race}; // Message body

                When I close developpement envorinnement, on re-open, and lauch the application, i have the message as the global variable is not existing.

                I must suppress .[old_race] in OnAfterIpdate, compile, lauch, and put it again!!!
                Then it's OK!!

                Do you have any idea??
                Best regards,
                Olivier

                Comment

                Working...
                X