You can't make any changes in db until a transac...

tompynation
Member Posts: 398
Hi,
i'm receiving the error when i try to execute a method from my subform.
In the onAfterGetCurrRecord i'm calling this method from my subform:
Form - OnAfterGetCurrRecord()CurrForm.GrondstofSUB.FORM.FillFilters(FabricatieID,Fabricatienr);
CurrForm.GrondstofSUB.FORM.FillGrondStofSamenStelling();
The error occurs in the FillGrondStofSamenStelling() method.
This method looks like the following:
FillGrondStofSamenStelling()
lv_PORegel.RESET;
lv_PORegel.SETRANGE(lv_PORegel.FabricatieID,gv_FabricatieID);
lv_PORegel.SETRANGE(lv_PORegel.Fabricatienr,gv_FabricatieNr);
lv_PORegel.SETFILTER(lv_PORegel.Item,'<>%1','');
IF lv_PORegel.FINDSET THEN BEGIN
REPEAT
IF lv_Item.GET(lv_PORegel.Item) THEN BEGIN
IF lv_Item."Item Category Code" <> 'F' THEN BEGIN
lv_POResultSamenstell.RESET;
lv_POResultSamenstell.ID := 0;
lv_POResultSamenstell.FabricatieID := gv_FabricatieID;
lv_POResultSamenstell.Fabricatienr := gv_FabricatieNr;
lv_POResultSamenstell.SamenstellingType := 'G';
lv_POResultSamenstell.Item := lv_Item."No.";
lv_POResultSamenstell.Omschrijving := lv_Item.Description;
lv_POResultSamenstell.Type := lv_Item."Item Category Code";
lv_POResultSamenstell.Hoeveelheid := lv_PORegel.HoeveelheidKG;
lv_POResultSamenstell.INSERT; END
ELSE BEGIN
// Item is Formule en moet verder opgesplitst worden
lv_Recept.RESET;
lv_Recept.SETRANGE(lv_Recept.ReceptCode,lv_Item."No.");
lv_Recept.SETFILTER(lv_Recept.IsActiefRecept,'TRUE');
IF lv_Recept.FINDFIRST THEN BEGIN
REPEAT
FillGrondStofTable(lv_Recept.ID);
UNTIL lv_Recept.NEXT = 0;
END;
END;
END;
UNTIL lv_PORegel.NEXT = 0;
END;
CurrForm.UPDATE(FALSE);
The error occurs as soon as i try to insert the record (see line in bold)
Anyone see why this would happen?
i'm receiving the error when i try to execute a method from my subform.
In the onAfterGetCurrRecord i'm calling this method from my subform:
Form - OnAfterGetCurrRecord()CurrForm.GrondstofSUB.FORM.FillFilters(FabricatieID,Fabricatienr);
CurrForm.GrondstofSUB.FORM.FillGrondStofSamenStelling();
The error occurs in the FillGrondStofSamenStelling() method.
This method looks like the following:
FillGrondStofSamenStelling()
lv_PORegel.RESET;
lv_PORegel.SETRANGE(lv_PORegel.FabricatieID,gv_FabricatieID);
lv_PORegel.SETRANGE(lv_PORegel.Fabricatienr,gv_FabricatieNr);
lv_PORegel.SETFILTER(lv_PORegel.Item,'<>%1','');
IF lv_PORegel.FINDSET THEN BEGIN
REPEAT
IF lv_Item.GET(lv_PORegel.Item) THEN BEGIN
IF lv_Item."Item Category Code" <> 'F' THEN BEGIN
lv_POResultSamenstell.RESET;
lv_POResultSamenstell.ID := 0;
lv_POResultSamenstell.FabricatieID := gv_FabricatieID;
lv_POResultSamenstell.Fabricatienr := gv_FabricatieNr;
lv_POResultSamenstell.SamenstellingType := 'G';
lv_POResultSamenstell.Item := lv_Item."No.";
lv_POResultSamenstell.Omschrijving := lv_Item.Description;
lv_POResultSamenstell.Type := lv_Item."Item Category Code";
lv_POResultSamenstell.Hoeveelheid := lv_PORegel.HoeveelheidKG;
lv_POResultSamenstell.INSERT; END
ELSE BEGIN
// Item is Formule en moet verder opgesplitst worden
lv_Recept.RESET;
lv_Recept.SETRANGE(lv_Recept.ReceptCode,lv_Item."No.");
lv_Recept.SETFILTER(lv_Recept.IsActiefRecept,'TRUE');
IF lv_Recept.FINDFIRST THEN BEGIN
REPEAT
FillGrondStofTable(lv_Recept.ID);
UNTIL lv_Recept.NEXT = 0;
END;
END;
END;
UNTIL lv_PORegel.NEXT = 0;
END;
CurrForm.UPDATE(FALSE);
The error occurs as soon as i try to insert the record (see line in bold)
Anyone see why this would happen?
0
Answers
-
if i try to insert a dummy record, so changing the subform method to this:
FillGrondStofSamenStelling()
lv_POResultSamenstell.RESET;
lv_POResultSamenstell.ID := 0;
lv_POResultSamenstell.FabricatieID := gv_FabricatieID;
lv_POResultSamenstell.Fabricatienr := gv_FabricatieNr;
lv_POResultSamenstell.SamenstellingType := 'G';
lv_POResultSamenstell.Item := '1021';
lv_POResultSamenstell.Omschrijving := 'Test';
lv_POResultSamenstell.Type := 'G';
lv_POResultSamenstell.Hoeveelheid := 1;
lv_POResultSamenstell.INSERT;
It also generates the error0 -
OnfterGetCurrRecord trigger is not good trigger for changing anything in the database. It is why you have this error. This trigger does not allow it. What do you want to do? There must be better way than using OnAfterGetCurrRecord trigger...0
-
If you browse through a record (OnAfterGetCurrRecord / OnAfterGetRecord) you will insert a new record in a other table, why this :?:
Why not if you insert / modify a reord on your base table, then insert / modify the record(s) in your sub table.
So i ask you, what do you want to do :?:
Give us some more infos and we will find the best solution for you
regardsDo you make it right, it works too!0 -
all i want to do is fill up a table for each record...
And then display this table in the subform.0 -
There is one main question - why you are generating the data "on fly", why they are not already created in the table and why you don't just filter this table for correct records. This is the NAV way...
It means, make sure, that you generates all records before you open the form and than just filter for the correct one. If you will generate the records each time someone move the cursor, it will not be usable...0 -
allright, i changed the way the creations works so the problem is now gone.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