Dynamic Temporary Table

doddwelldoddwell Member Posts: 65
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.

Comments

  • whitaker_timwhitaker_tim Member Posts: 23
    I think I understand the situation but just to be clear, you have a function which essentially populates information into a table or tables in NAV. What you would like to do is have the user preview this data before NAV commits this to the database. I do not think that you need a temporary variable to accomplish what you require, here is a suggestion.

    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).
    Tim Whitaker | Senior NAV Consultant/Developer | The Software Workshop Ltd. | http://www.thesoftwareworkshop.com
  • doddwelldoddwell Member Posts: 65
    Hello Tim

    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
  • whitaker_timwhitaker_tim Member Posts: 23
    I would most likely approach this differently for multiple users, it would really depend on the type of transactions and where along the process you want to present the data to the user. Without knowing the specifics of the data being created and presented it is difficult to provide an exact answer, only suggestions on how to approach.
    Tim Whitaker | Senior NAV Consultant/Developer | The Software Workshop Ltd. | http://www.thesoftwareworkshop.com
  • kapamaroukapamarou Member Posts: 1,152
    It doesn't matter who will run your process and how. You should always write your code with concurrency in mind. ERP systems are concurent.

    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.
  • vaprogvaprog Member Posts: 1,141
    doddwell wrote:
    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.
    You should consider to implement the concept of a worksheet used so frequently in NAV.
    doddwell wrote:
    - dynamically control whether a record variable is temporary or not temporary
    You can do this by using RecordRef, but that's rather combersome.
    doddwell wrote:
    - 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.
    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.
Sign In or Register to comment.