Setting boolean flag on a table
                
                    hav                
                
                    Member Posts: 299                
            
                        
            
                    Hi,
I am using NAV 2009 NA-ENG SP1.
I have added a boolean var. IsWMItemDeletionReqd and a function SetIsWMItemDeletionReqd() to SalesLine table as below.
I am calling the above function from the OnDeleteRecord() trigger of Sales Order Subform as below
And the OnDelete() trigger of Sales Line table is as below
The objective is that when user deletes a sales line from either the Sales Quote or Sales Order form, the program first calls OnDeleteRecord() of the underlying subform wherein i first set the flag IsWMItemDeletionReqd to true in SalesLine table so that when later OnDelete() trigger of the underlying table is called, the function WMI.DeleteItem() should get called.
However the problem is inspite of setting the flag from the subform when i later access it in the salesline table, the flag is not seen as True and hence my function is not getting called.
Am i missing something?
Regards,
Hemant
                I am using NAV 2009 NA-ENG SP1.
I have added a boolean var. IsWMItemDeletionReqd and a function SetIsWMItemDeletionReqd() to SalesLine table as below.
SetIsWMItemDeletionReqd(flag : Boolean)
BEGIN
    IsWMItemDeletionReqd := flag;  //IsWMItemDeletionReqd is a global boolean var.
END
I am calling the above function from the OnDeleteRecord() trigger of Sales Order Subform as below
Form - OnDeleteRecord() : Boolean
IF (Quantity <> 0) AND ItemExists("No.") THEN BEGIN
  COMMIT;
  IF NOT ReserveSalesLine.DeleteLineConfirm(Rec) THEN
    EXIT(FALSE);
  ReserveSalesLine.DeleteLine(Rec);
END;
// Execute WMERP code only if WM add-on is enabled
IF NOT WMI.IsWMAddOnDisabled() THEN BEGIN
  // Restrict deletion of G/L Account type of WM Sales Lines directly
  IF (Type = Type::"G/L Account") AND (WMItemNo <> '') THEN BEGIN
    MESSAGE(TEXT002);
    EXIT(FALSE);
  END ELSE BEGIN
    // Set flag to mark deletion of WM Item along with current salesline
    SetIsWMItemDeletionReqd(TRUE);
    EXIT(TRUE);
  END;
END;
And the OnDelete() trigger of Sales Line table is as below
OnDelete()
BEGIN
  ...............
  IF IsWMItemDeletionReqd THEN BEGIN
    // Delete WM Item corr. to Sales Line of type Item only. 
    IF (Rec.WMItemNo <> '') AND (Rec.Type = Rec.Type::Item) THEN
      WMI.DeleteItem(SalesHeader, Rec);  //WMI is a codeunit
  END;
END;
The objective is that when user deletes a sales line from either the Sales Quote or Sales Order form, the program first calls OnDeleteRecord() of the underlying subform wherein i first set the flag IsWMItemDeletionReqd to true in SalesLine table so that when later OnDelete() trigger of the underlying table is called, the function WMI.DeleteItem() should get called.
However the problem is inspite of setting the flag from the subform when i later access it in the salesline table, the flag is not seen as True and hence my function is not getting called.
Am i missing something?
Regards,
Hemant
Regards,
Hemant
MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)
Hemant
MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)
0                
            Answers
- 
            Maybe a case similar to this?
viewtopic.php?f=23&t=41868&hilit=variable+cleared0 - 
            Thanks for your response.
I have now worked out in below manner:
Added IsWMItemDeletionReqd global var. to WMI codeunit instead of SalesLine table
Moved the SetIsWMItemDeletionReqd() function from SalesLine table to WMI codeunit.
So now from the OnDeleteRecord() trigger of the Quote & Order subform, i make a call asForm - OnDeleteRecord() : Boolean BEGIN .......... WMI.SetIsWMItemDeletionReqd(TRUE); END;and from the OnDelete() trigger of Salesline table,OnDelete() BEGIN ............... // Delete WM Item corr. to Sales Line of type Item only. IF (Rec.WMItemNo <> '') AND (Rec.Type = Rec.Type::Item) THEN WMI.DeleteItem(SalesHeader, Rec); //WMI is a codeunit WMI.SetIsWMItemDeletionReqd(FALSE); END; END;and from the DeleteItem() of the WMI codeunit,DeleteItem(VAR SalesHeader : Record "Sales Header";VAR SalesLine : Record "Sales Line") BEGIN //Restrict deletion to WM Item if only sales line is to be deleted IF NOT IsWMItemDeletionReqd THEN EXIT; .......... END;
The above works fine.
Regards,
HemantRegards,
Hemant
MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)0 
Categories
- All Categories
 - 73 General
 - 73 Announcements
 - 66.7K 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
 - 323 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