Possible to pass Temp Table between two objects?

XypherXypher Member Posts: 297
If possible, by what method would I have to go about to "share" a temporary table between two objects?

Comments

  • girish.joshigirish.joshi Member Posts: 407
    You have a couple of options.

    One is to use a single instance codeunit. Your temporary variable is stored and manipulated there. This can be difficult to manage; it is only really an option when you have a large amount of data stored in your temp table that you want to pass around.

    The other option is to use a "copy constructor" when you pass a temp table by reference between objects, you don't get access to to the records stored in the temp table in the called object. Therefore you need to create a local temp variable, and copy records into/out of it, for use where you need.
    In general, this is the better approach.

    Finally, you can try using a real table. You will need to add session id as part of the primary key.
  • kinekine Member Posts: 12,562
    And best way is to pass the record variable by reference (as parameter for some function using VAR for the parameter). Than you can do what you want in the function and when the function finished, you have the modifications in your calling object too... but all depends on what you want to do... 8)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.