As part of 2017 any call to Insert, Modify etc throws an error when called inside a Try Function. This is because Try Functions should not really be used for this kind of functionality and you should refactor the code to use IF CODEUNIT.RUN instead.
If this isn't an option, you can edit the value of the DisableWriteInsideTryFunctions setting in the CustomSettings.config file.
As part of 2017 any call to Insert, Modify etc throws an error when called inside a Try Function. This is because Try Functions should not really be used for this kind of functionality and you should refactor the code to use IF CODEUNIT.RUN instead.
If this isn't an option, you can edit the value of the DisableWriteInsideTryFunctions setting in the CustomSettings.config file.
You can use the DisableWriteInsideTryFunctions as a temporary measure but you should restructure your code so that you do not have database changes within the TryFunction. The reason this restriction was added was for database integrity as the initial implementation of TryFunctions could result in partially committed / partially rolled back data.
Answers
Check this article -https://msdn.microsoft.com/en-us/dynamics-nav/handling-errors-by-using-try-functions
As part of 2017 any call to Insert, Modify etc throws an error when called inside a Try Function. This is because Try Functions should not really be used for this kind of functionality and you should refactor the code to use IF CODEUNIT.RUN instead.
If this isn't an option, you can edit the value of the DisableWriteInsideTryFunctions setting in the CustomSettings.config file.