trigger in a table

nunziosnunzios Member Posts: 4
edited 2004-05-21 in Navision Attain
in OnInsert trigger of a table I Have inserted some code. The trigger is not always executed. Why it is not always executed every time I insert a new record?

Thanks.

Comments

  • arunarun Member Posts: 4
    Put <record>.insert(TRUE) if u want the Oninsert trigger to run..
  • WarfoxWarfox Member Posts: 53
    That is not only so for the OnInsert trigger, the same thing is it at the OnModify (<record>.modify(TRUE)) or the delete and the rename.
  • WarfoxWarfox Member Posts: 53
    That is not only so for the OnInsert trigger, the same thing is it at the OnModify (<record>.modify(TRUE)) or the delete and the rename.
  • nunziosnunzios Member Posts: 4
    :D Thanks for the answare, but unfortunatelly it is not the solution for my problem

    :( What I would like to do is to replicate a table (i.e. "Item Ledger Entry") in a new table

    to do so I inserted under the "OnIsert"/OnModify/OnDelete section of the original table some code

    the problem is that it doesn't execute the trigger when I insert/Modify/delete for example trought a "post"
  • WarfoxWarfox Member Posts: 53
    if you want to replicate a table why dont u use the transferfields command?

    what do you mean with POST???
  • RobertMoRobertMo Member Posts: 484
    What nunzios means, when someone posts a transactions with Items, he would like to copy ILE to second table. (Posting of purchase/sales orders/ Item Journals, etc.)

    nunzios, check CU22 function InsertItemLedgEntry, where ILE are being inserted. Fix the line at the near end of function from
    ItemLedgEntry.INSERT;
    
    to
    ItemLedgEntry.INSERT(TRUE);
    
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  • WarfoxWarfox Member Posts: 53
    ahh ok,

    if you want to have alway´s the same data in the 2 tables the best thing
    would be:

    OnInsert()
    Table2.transferfields(rec);
    Table2.insert;

    OnModify()
    Table2.Transferfields(rec);
    Table2.modify;

    .. and so on

    Table2 is your destination table for the update;
  • RobertMoRobertMo Member Posts: 484
    To be more error free use:
    OnInsert()
    Table2.transferfields(rec);
    If not Table2.insert then Table2.modify;

    OnModify()
    Table2.Transferfields(rec);
    If not Table2.insert then Table2.modify;

    but still this is not enought. If you really want your table2 to be allways updated, you must ensure that all calls in every code will trgger OnInsert and OnModify - that means INSERT must be called with TRUE parm and MODIFY the same. If you omit parm, it is FALSE by default.
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  • nunziosnunzios Member Posts: 4
    :D
    Thanks Arun/Warfox/RobertMo
    I have sorted out my problem and our code looks much better and is more efficient

    We are managing a intercompany logistics problem
    If you are interested in the explanation of the entire architecture I would be happy to discuss it with you
Sign In or Register to comment.