Hello
I have a Codeunit that inserts some data into a table "myTable". I'd like the user to be able to see the data in Excel prior to the data being inserted - so I am planning to use a temporary table. I can write a "Preview" function but I am hoping I can amend the first function to either:
- dynamically control whether a record variable is temporary or not temporary
OR
- create 2 record variables ("recmyTable" not temporary, "recmyTableTemp" temporary) and another 3rd variable (not sure what type) and then assign "recmyTable" or "recmyTableTemp" to the 3rd variable.
Is this possible or should I write a second function?
Many Thanks.
0
Comments
Before the function completes export the data to excel for the user to review, once exported provide the user with a confirm message so that the function process stops until the user answers the question.
1. If the user answers with a positive to continue the function then continue and the data will be saved to NAV.
2. If the user answers with a negative that the results are not correct or inappropriate, then provide the user with an error stating that this process has been user cancelled. The error message will rollback any data changes and the information will not be saved in NAV (this is assuming that a COMMIT has not been called during the processing of the function).
Thanks for you suggestion - I hadn't considered that but can see how it will be a useful technique without having to do any more work. This particular module I'm writing will only have one user performing the processing at any one time so your suggestion might do the trick. Would you still approach it in the same way if multiple users are processing at the same time - I'm thinking about number series getting out of sync and table locking.
Thanks, Simon
That being said, you cannot start a process that writes to tables and shows a modal dialog before the transaction has completed (successfully or not). The system will not let you do that. In similar cases I always use temporary tables to collect the data, present it to the user and at the end transfer that data to the actual tables.
You can do this by using RecordRef, but that's rather combersome.
You can do that using VAR parameters to functions. Dependent on the actual parameter you pass to the function, the function will process records in a temporary or live table.
I don't see, though, how these requests of yours pertain to the solution you are looking for.