Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Forums / Finance forum / Issue with clearing ta...
Finance forum
Under review by Community Managers

Under review

Thank you for your post! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Issue with clearing table buffers in called class.

Posted on by
Hello,
 
I have a logic where I am looping though a queryRun object in class A and inside the loop I am calling class B and passing the table records of the query as parameters:
Logic of class A:
public void run()
{
         ClassB classB = ClassB::construct();
         while (queryRun.next())
         {
             if (queryRun.changed(tableNum(InventTable)))
             {
                 InventTable                 inventTable             = queryRun.get(tableNum(InventTable));
                 EcoResCategory          ecoResCategory     = queryRun.get(tableNum(EcoResCategory));
 
                 classB.createDefails(inventTable,
                         ecoResCategory);
            }
        }
}
Logic of class B:
public void createDetails(InventTable _inventTable, EcoResCategory _ecoResCategory)
{ //line 7
    inventTable.clear(); //line8
    ecoResCategory.clear(); //line9
  
    inventTable                    = _inventTable;
    ecoResCategory             = _ecoResCategory; 
    //processing logic
}
 
In class B, I have global variables InventTable and EcoResCategory which will be used. I have added a logic in class B's createDetails to clear those 2 variables. However, I have a very weird behaviour where upon clearing those 2 variables of class B, the variables passed as parameters (_inventTable and _ecoResCategory) are also being cleared. It works fine when the logic of createDetails is executed for the first loop, but then for the following loops both the global variables and parameter variables become null after the line 9 execution. When debugging, _inventTable and _ecoResCategory have their respective records at line 7 but then they become null after line 9.
I have commented line 8 and 9 and it works fine now but I could not understand why they were causing this issue.
Has anyone had this issue before?
 
 

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard >

Featured topics

Product updates

Dynamics 365 release plans