Trigger to insert record

BokkBokk Member Posts: 138
edited 2005-09-27 in Navision Attain
I have been asked to automate the process to create a product order in the Sales Order form. It is usually done using the ORDER menu button -> Planning, then FUNCTIONS menu button -> Create prod. order. I have added a boolean field in the details (Sales Line) and check it in the OnValidate trigger of the table, then run the same code they do. However, the Sales Line record hasn't been saved yet, so it doesn't fill the next form with the data. In the Sales Order form, the record is added either on a new line or when a menu or command button is clicked. Is it possible to trigger the add myself (an Insert was not allowed)? It seems to happen behind the scenes. Not surprisingly, there seem to be a few issues arise when you change the type of object the code is being called from.

Just knowing if this is possible, or a suggestion for a different approach would be great.

Thanks!
SGM

Comments

  • SbhatSbhat Member Posts: 301
    Hi,

    I would first follow a different approach. First i would create a boolean field on the sales line and at the time of posting in Codeunit 80 i would create a function which would check for the sales line where the boolean field is checked off and for those lines i would replicate the same create. prod. order function. This way you are not locking any table and is a clean way of doing this task.

    Thanks
    Best regards
    Suresh.
    NJ
  • BokkBokk Member Posts: 138
    I think some additional info is needed. This company does manufacturing, but essentially everything is customized. Each time they select an item that has a BOM, they would like it exploded automatically. The product order must be done before the BOM is exploded. (The person on the phone selects an item, which should explode so they can customize the bill of materials for that order.) They would like this to happen immediately on each line.

    Thanks
    SGM
  • StephenGStephenG Member Posts: 99
    Hi

    Have you tried adding the code to the "Sales Line" Form. You could add the code to The OnAfterValidate Trigger of Field "No.". For an example look at the OnAfterValidate trigger for field "Quantity" on the "sales Line" form this is used for Reservations.
    Answer the question and wait for the answer.
  • mkesslermkessler Member Posts: 6
    Bokk maybe this Topic help u.
    Its for Navision Financials but iam sure should work for u too.
    I didn't read all, just did a fly throu but sounds like they have a conclusion to simulate a Buttonclick from Code.

    http://www.mibuso.com/forum/viewtopic.php?t=598&highlight=click
  • DenSterDenSter Member Posts: 8,307
    Instead of trying to squeeze this into some validation code, I would do this as part of the release Sales Order function. That way you are guaranteed that the sales order is in a 'complete' state. Just debug the manual process and mimic it in code, this one should not be very difficult.
Sign In or Register to comment.