Announcement

Collapse
No announcement yet.

onbeforeinsert - I must be stupid!

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

  • onbeforeinsert - I must be stupid!

    I'm almost embarrassed to ask such a basic question, but this is driving me crazy;

    The Help file reads: onBeforeInsert - This event runs before insert a record.

    In every other programming environment I use the "onbeforeinsert" event is used to initialise fields in the new record. By example

    {mycompanyid} = (some_other_valid_data_table.valid_value);

    Why doesn't this work in SC?
    Last edited by GuiGuy; 05-22-2015, 09:30 PM.
    The GuiGuy
    ... from Down Under

  • #2
    GuiGuy

    At what point do you believe the event is being called?

    If you are trying to initialise fields it sounds like you are expecting the onBeforeInsert to run at the point just after you click Add New button, i.e after clicking the New button but before the form is displayed? I'm sure you know this, but that's not the case? Perhaps just can't see the woods for the trees (like my recent virtual fields in searches snafu)? So just a recap of what I know you already know... :-)

    onBeforeInsert will run at the point you try and save a new record - so if you were trying to initialise fields on a "new" form, then that bit has long gone by the time onBeforeInsert is run. You need to use onLoad instead, and check if fields are null / empty - and then initialise if needed.

    Or are you - at the save / update record point - wanting to initialise / set either hidden fields or fields in other table fields - in which case onBeforeInsert or onBeforeUpdate respectively are the right places.

    :-)
    Last edited by adz1111; 05-23-2015, 06:48 AM.

    Comment


    • #3
      Originally posted by adz1111 View Post
      GuiGuy

      onBeforeInsert will run at the point you try and save a new record -
      :-)
      Thanks. I see the issue now. (I'm a long time Delphi coder and used to initialising fields in the "onafter_insert" event. The event as it works in SC is more like the "onbefore_post" in Delphi etc.)

      My coding knuckles consider themselves slapped and the paradigm has been adjusted accordingly.

      Cheers
      The GuiGuy
      ... from Down Under

      Comment

      Working...
      X