Options

afterInsert trigger ?

GetteGette Member Posts: 19
edited 2006-03-07 in Navision Financials
When I enter a new record via a form, I need to copy the record in another table in a specific format. I created the code and it worked with some test values.

The problem is that when I run the code in the onInsert trigger, the record isn't inserted yet and then I can not lookup values of the record.

Is there something like an afterInsert trigger or another way to do this ?

Thanks in advance,

Geert

Comments

  • Options
    kinekine Member Posts: 12,562
    When you are in OnInsert you have all values in Rec... what do you want to lookup? :?:
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    GetteGette Member Posts: 19
    I pass the ID of an employee record to a codeunit. This codeunit then uses the xmlport to extract an xml file.

    The problem is when I 've added a new record, this new record is not yet in the employee table because I use the onInsert trigger.

    If I use the rec, then I must create my xml file manually.

    Any tips are welcome because I'm quit new in Navision and don't know what all the objects can do.

    Kind regards,

    Geert
  • Options
    AbrahamAbraham Member Posts: 7
    You can use the onModify trigger of the table to copy or update the record in the secondary table, each time you modify the record in your source form, the onModify trigger of the table will run and update the other table.

    Another idea is to create a button in your form that will export the contents of any record in the table to the other table.
    Abraham
  • Options
    kinekine Member Posts: 12,562
    Pass whole record into the codeunit instead ID only...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    nasonaso Member Posts: 11
    This brutal hack simulates an onAfterInsert trigger.

    OnInsert
    Rec.INSERT;
    //Do what you need to do after insert
    Rec.DELETE; // Delete the Rec so navision can add it.

    I would appreciate comments.

    Cheers
  • Options
    dlacabadlacaba Member Posts: 17
    naso wrote:
    This brutal hack simulates an onAfterInsert trigger.

    OnInsert
    Rec.INSERT;
    //Do what you need to do after insert
    Rec.DELETE; // Delete the Rec so navision can add it.

    I would appreciate comments.

    Cheers

    That is Brutal :P

    Just used it in a similar situation I was having and it seems to work just fine. I'll keep testing to make sure it works correctly.


    edit: also works for making an OnAfterModify trigger.

    OnModify
    Rec.MODIFY;
    // OnAfterModify Code


    Thanks naso!
Sign In or Register to comment.