Copying Dimension from one table to another on insert record

gemini_shootergemini_shooter Member Posts: 149
Hello All,

I have this unique situation with a client. The client uses a Mfg. Dimension on the manufacturer's table and wants to copy the dimension to item card when the item is created.

I have the piece that does the copying but here are two instances when the it will run

1. OnInsert Trigger when inserting an item into the item table. (DOES NOT WORK)

2. On validate of Manufacturer's code, when changing the manufacturer's code on the item. (THIS WORKS)

The reason 1. does not work is because I have the item no. after on insert is finished. So my question is is there a way to have trigger like OnAfterInsert or whats the best way of making sure that onInsert also Inserts the dimension in the Default dimension table


  • Options
    kapamaroukapamarou Member Posts: 1,152
    The 2nd seems to be correct.

    When you insert a new Item, is the manufacturer's code filled? If it is blank, which dimension is used?
  • Options
    gemini_shootergemini_shooter Member Posts: 149
    kapamarou: I need both 1 and 2. Its not that which one is correct. I am trying find the best way I can insert the dimension at the time of inserting a new record. So when I insert the Manufacturer's code, it should insert the dimension as well.

    Problem is that the primary key (No.) is inserted at the very end, because it uses a combination of "Mfg Code"+Vendor No+etc.

    So I need a way I can update the dimension on the item card right after the primary key is inserted or the OnInsert is complete.. hence the questions "Is there an OnAfterInsert()"?
  • Options
    Cali_KoppersCali_Koppers Member Posts: 19
    Posted in the wrong thread. Can't delete?
  • Options
    gemini_shootergemini_shooter Member Posts: 149
    Still not sure how to handle this issue.

    I Need a way to run the OnModify Trigger after OnInsert Trigger has fully completed. Is it possible?

    Here is the summary I have as of now:

    1. When I try to create a new item
    2. A custom form and codeunit runs and gathers all the information on the form. (At this point in time the No. (PKEY) is not assgined because it is created dynamically
    3. click OK on this custom form
    4. It brings me back to the item form with a blank No. field (Still no No. so no PKEY)
    5. Focus is on "No". Field; System pops a message saying "Tab Off to create the new item"
    6. Hit the TAB key on my keyboard and the OnInsert Trigger is now run on the Item table and validates all fields.
    7. Runs a custom function at the very end which combines (Manufacturer's code+Vendor Item No to create a Item No. (Finally I have the PKEY for item and record is inserted)
    8. On Insert Trigger is finished now

    9. PROBLEM****: I would like to run some more validations now; since I have a new no. and new item and update default dimension using the default dimension on the Manufacturer's code.

    I have the function for No. 9 but I am not sure of the trigger I can place it, probably OnModify(), but this trigger should run all the time after OnInsert is finished. I can use a flag in OnInsert to run it only for new items, but I want to run after Insert has completely finished. Can anyone please help.
  • Options
    redhotmustangredhotmustang Member Posts: 91
    Same problem here!

    I need to insert records on an auxiliary table when a new record is inserted on the main table.
    I placed a call to a custom function (which inserts the necessary records on the auxiliary table) at the very end of the OnInsert() trigger.

    This auxiliary table needs the "No." (of course, since it is an auxiliary table... :mrgreen:) from the main table to proceed with its insert function, since "No." is not yet available (although the IF "No." <> '' says it is) it becomes impossible to accomplish my goal.

    As we know if any error occurs on the OnInsert() trigger, nothing is inserted anywhere.

    The only way I figured out to do this is to place the custom function call on the OnValidate() trigger of one of the fields of the main table that needs to be filled out by the user (but it is not mandatory).

    Redcodestudio: Web Development, FLASH & Webdesign (and a little NAV, in the future)
  • Options
    TankTank Member Posts: 1
    Here is a solution that worked for me in a similar situation.
    I have a custom Cost Table where cost are stored for various customer/vendor/location/state/etc combinations. The company wanted alot of extra functionality that the Navision Sales Price and Purchase Price did not have. They also want cost to be update automatically on the document lines when a new cost is inserted into the Cost Table. There was the problem. If I called the UpdateCostOnDocumentLines() method on the Insert trigger of the Cost Table, The Cost Table record did not exist yet.

    I placed this code in the Form - OnInsertRecord trigger of my Cost Card.

    I hope that this may be some help to you.

Sign In or Register to comment.