Created a new table when posted the order data should flow in new table

I created a new table and took the fields in sales line also when i post the sales line then i need to update the date in the new table.
can anyone please help me regarding this issue
Thanks in advance.

Answers

  • xenosxenos Member Posts: 16
    I'm very new to NAV C/AL.
    But i think what you must do is to:
    1. Create a new table (seems like you have).
    2. Create column with name "Last Timestamp (whatever)" and give it data type DateTime.
    I think you did as much already. Now go and find the relevant page where the sales lines is posted from.

    Now you need to go to the page where the normal activity you want to react to is happening.
    Enter the C/AL code of that page and you get a lot og triggers (i think you know this).


    3. Add Table relation via. variable [name:MyTableRel, Datatype: Record, Subtype: Your new table name/number. So now you have a table which can access the new table you've created.

    5. Add a code which updates the datetime of your new table.
    So in the C/AL code of your page. Find the relevant trigger which fits your case.
    Probably OnInsert or Modify.
    So you need this page to tell the modify your tables Coulmn whenever a new record is inserted into the table Sales Lines (37).
    I don't know the code so i'll just guess (i'm assuming it's as simple as):
    In this example i'll assume that the name of the table relation variable is myRelation and the new table has a column called myTimeStamp.

    Variable:
    Name DataType Subtype
    myRelation Record MyNewTable

    C/AL:
    OnInsert()
    myRelation.myTimeStamp := CURRENTDATETIME;
    myRelation.Insert;

    And if you want to specify the DateTime format, you can
    myRelation.MyTimeStamp := FORMAT(CURRENTDATETIME,0,'<Day,2><Month,2><Year4>');
    Oh which ever way around you want it depending on where you are :)
    Let me know if it works :D


  • lubostlubost Member Posts: 623
    1. What is the reason to have the same record from sales line in another table? There exists sales archive.
    2. If you want use your solution, find command TRANSFERFIELDS in codeunit 80 and do the same with your table.
Sign In or Register to comment.