Announcement

Collapse
No announcement yet.

Validation

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

  • Validation

    What is the purpose of the forms event
    - OnValidate
    - OnValidateFailure
    - OnValidateSuccess

    How would it validate success or fail?

    How to make use of these event?

    Thanks

    GT

  • #2
    The onvalidate event is triggered when you click save or new after insert or update. Here you can add additional checks on your data. If you generate an error then onvalidate failure is executed, otherwise the onvalidate success. In the first case the update is not done, in the second case the update is done at the very end of onvalidate success. In the onvalidate success you can do additional things. It depends on your needs.
    Albert Drent
    aducom software netherlands
    scriptcase partner, reseller, support and (turn-key) development
    www.scriptcase.eu / www.scriptcase.nl

    Comment


    • #3
      From program help (click on ? in the editor from event OnValidateFailure):

      This event occurs when submitting the application in OnValidate, has errors generated by macros sc_error_exit, sc_error_message, or error detected by scriptcase (errors related to Database).
      Now read the help text for sc_error_message:

      This macro generates an error messages.

      In "Form and Control" applications, the messages are presented together with other error messages found in the application, except when using the "sc_error_exit" macro.

      In "Grid and Menu" applications the messages only will be presented through the "sc_error_exit" macro.


      Ex. 1:
      if ({discount} > 0.10 && [glo_usr] == 'operator')
      {
      sc_error_message("Discounting of " . {discount} . " above of the allowed one");
      }

      In this example, if the value in the discount field is over 0.10 and the user try to add or save this record, the operation is finished and the error message is presented.The command must finish with ");" (close parentheses and semicolon) used as delimiter for the macro interpreter.
      In this example you "generate" the failure message and validate is not success.
      Best regards: - Reinhard -

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

      Comment


      • #4
        Is there a way to generate an error without using sc_error_message so that the event onValidateFailure can be triggered?
        I do not want to display an error message?

        Comment


        • #5
          Most simple solution is to put your onValidateFailure code into a php method and call that from your onValidateFailure or anywhere else.
          Albert Drent
          aducom software netherlands
          scriptcase partner, reseller, support and (turn-key) development
          www.scriptcase.eu / www.scriptcase.nl

          Comment

          Working...
          X