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?
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
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.
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
Comments
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"
what do you mean with POST???
nunzios, check CU22 function InsertItemLedgEntry, where ILE are being inserted. Fix the line at the near end of function from to
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
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;
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.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
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