Inserting/modifying a table field

ImaspalImaspal Member Posts: 68
Hi Experts!

I have made a new field to a table. Data to this field is calculated using data from another field of the same table.

Now I'm wondering, where all places (triggers) I have to place the function call to the function, that calculates the value to this new field? The value to the new field have to be calculated at least, when new data is inserted to the table and when the old data is modified, is there other important situations, when the data to the new field have to be calculated?

When I have finished this table and my customer imports it to his/her system and there is allready data in this table, is there a way to make sure, that right data is automaticly calculated to the new field?

Mr. Nice Guy


  • EugeneEugene Member Posts: 309
    if the value of your new field can be calculated from other values of the same record then THERE IS NO NEED TO SAVE IT in the database.
    Reading data from disk is slower than calculating value in memory!!!
    Classical example is Age field which is not saved in the table but calculated based on birthdate (which is saved). It would be crazy to update age every day - right ?

    you cannot have virtual field in table but you can create virtual column on the form and set its SourceExpr=MyFunctionWhichCalculatesValue

    then define the function MyFunctionWhichCalculatesValue somewhere in the form and write its code using Rec variable to access current record fields values. Navision will call your function whenever necessary

    Ah one more thing - to create virtual column - drag and drop TextBox control onto the grid
  • ImaspalImaspal Member Posts: 68
    Thank you for your guidelines. They could be valuable in future.

    In this case, however, I have a specification, where the new field to the table is required.

    Also the value to the new record is not calculated only using the values of the same record. Values from another table are also needed.

    In these circumstances, is it enough to place the function call (MyFunctionWhichCalculatesValue) to OnModify- and OnInsert-triggers?

    The other question is, how this modified table acts, when it is imported to the other database, where the same table exists with data? I'm asking a clever way to make sure, that the new field gets its values.

    Mr. Nice Guy
Sign In or Register to comment.