Fill table in trigger OnAfterGetCurrRecord

edoderooedoderoo Member Posts: 89
In NAV2016 I created a list page, that shows my projects. When I select a project, it will fill a second list page with some details of my project.
I created an action trigger to fill this, and this works smoothly.

Now I try to fill the same data out of the OnAfterGetCurrRecord trigger, and it shows an error stating: "A transaction should be started before changes in the database can be made". This error will *not* appear when my function does not make any changes to the data, but every delete/modify/insert will throw this error.

Is it true that you can not make changes to the database in the OnAfterGetCurrRecord trigger?
Is there a workaround?
IF User.Loves('Edo') THEN ok() ELSE currReport.genSkip;

Best Answer

  • KishormKishorm Member Posts: 921
    Answer ✓
    Correct, you cannot make database changes in that trigger.

    I'm not sure of your exact requirements but is it a possibility for you to populate a temporary table and show that on the second page? If you do this then it won't give an error because you are not writing changes to the database.

Answers

  • KishormKishorm Member Posts: 921
    Answer ✓
    Correct, you cannot make database changes in that trigger.

    I'm not sure of your exact requirements but is it a possibility for you to populate a temporary table and show that on the second page? If you do this then it won't give an error because you are not writing changes to the database.
  • edoderooedoderoo Member Posts: 89
    I will give that a try ... the name of the table is already TempSomething, and I delete all data on closing the form... but I'll try it with the temp-table property instead. Thanks for the tip!
    IF User.Loves('Edo') THEN ok() ELSE currReport.genSkip;
  • KishormKishorm Member Posts: 921
    Well if that's what you are doing then a Temporary table is exactly what you need.

    You can set the SourceTableTemporary of the page to "Yes" and then insert records into the Rec on the page. I normally do this by having a PopulateData() function on the list page which does this and then call this function from the OnAfterGetCurrentRecord trigger of the parent page.
Sign In or Register to comment.