Setting and accessing global variable

hav
Member Posts: 299
Hi All,
I am facing problem with setting and accessing a global boolean var.
I have added a global boolean var. CalledFromSynchronisation to SalesLine table. This table contains a fn. to set the value of this var.as shown below:
SetCalledFromSynchronisation(Flag : Boolean)
{
CalledFromSynchronisation := Flag;
}
I have a codeunit which modifies the SalesHeader record as below:
UpdateSalesHeader(VAR SalesHeader : Record Sales Header)
{
....................
SalesHeader.VALIDATE("Sell-to Customer No.");
..........
}
The above validation calls the below fn. of SalesHeader table
RecreateSalesLines()
{
...............
//Purpose : Set synchronisation flag to restrict deletion of Items
SalesLine.SetCalledFromSynchronisation(TRUE);
SalesLine.DELETEALL(TRUE);
....................
}
Note: Modified code is in red bits
When the OnDelete() of SalesLine table is called from the above fn. and i debug the OnDelete(), what i found is that the global boolean var. CalledFromSynchronisation is not set to TRUE in spite of settting it explicitly from RecreateSalesLines(). The OnDelete() of SalesLine table is as follows:
OnDelete()
{
.......
IF NOT CalledFromSynchronisation THEN
//do someting
.......
}
While debugging when i place curson at CalledFromSynchronisation var. above it shows me "No"
I am unable to trap this.
Pls help.
Regards,
I am facing problem with setting and accessing a global boolean var.
I have added a global boolean var. CalledFromSynchronisation to SalesLine table. This table contains a fn. to set the value of this var.as shown below:
SetCalledFromSynchronisation(Flag : Boolean)
{
CalledFromSynchronisation := Flag;
}
I have a codeunit which modifies the SalesHeader record as below:
UpdateSalesHeader(VAR SalesHeader : Record Sales Header)
{
....................
SalesHeader.VALIDATE("Sell-to Customer No.");
..........
}
The above validation calls the below fn. of SalesHeader table
RecreateSalesLines()
{
...............
//Purpose : Set synchronisation flag to restrict deletion of Items
SalesLine.SetCalledFromSynchronisation(TRUE);
SalesLine.DELETEALL(TRUE);
....................
}
Note: Modified code is in red bits
When the OnDelete() of SalesLine table is called from the above fn. and i debug the OnDelete(), what i found is that the global boolean var. CalledFromSynchronisation is not set to TRUE in spite of settting it explicitly from RecreateSalesLines(). The OnDelete() of SalesLine table is as follows:
OnDelete()
{
.......
IF NOT CalledFromSynchronisation THEN
//do someting
.......
}
While debugging when i place curson at CalledFromSynchronisation var. above it shows me "No"
I am unable to trap this.
Pls help.
Regards,
Regards,
Hemant
MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)
Hemant
MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)
0
Comments
-
try to loop through the saleslines and do delete(true) instead of deleteall(true)0
-
The code in green bits is the Navision code. The code which i have modified is shown in red bitsRegards,
Hemant
MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)0 -
Some triggers are running in their own "instances". It means when you call DELETEALL(true), you can "look behind the code" and see something like:
if FIND('-') then repeat InternalVar := Rec; InternalVar.DELETE(True); until NEXT=0;
It means that there is no flag set in the InternalVar instance of the table. As ara3n wrote, try to use the loop instead DELETEALL.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions