Form - OnAfterGetRecord() ShowShortcutDimCode(ShortcutDimCode); Form - OnAfterGetCurrRecord() CurrForm.UPDATECONTROLS; CurrForm.CAPTION("Document No."); //DSW-ARH 4/13/10 ++++++++++ IF (Type = Type::Item) AND ("No." <> '') THEN CreateSummary; //DSW-ARH 4/13/10 ---------- Form - OnBeforePutRecord()Function in the sales line table:
CreateSummary() TempILE.RESET; TempILE.SETRANGE("Quote No.","Document No."); TempILE.SETRANGE("Item No.","No."); TempILE.DELETEALL; <----------------Error occurs here QtyTotal := 0; ILE.RESET; ILE.SETCURRENTKEY("Item No.","Variant Code","Location Code"); ILE.SETRANGE("Item No.","No."); ILE.SETRANGE(Open,TRUE); ILE.SETRANGE(Positive,TRUE); IF ILE.FINDFIRST THEN REPEAT ILE.CALCFIELDS("Cost Amount (Actual)","Reserved Quantity"); UnitCost := ILE."Cost Amount (Actual)" / ILE.Quantity; QtyAvailable := ILE."Remaining Quantity" - ILE."Reserved Quantity"; QtyTotal := QtyTotal + (ILE."Remaining Quantity" - ILE."Reserved Quantity"); IF NOT TempILE.GET("Document No.",ILE."Item No.",ILE."Variant Code",ILE."Location Code",UnitCost) THEN BEGIN TempILE.INIT; TempILE."Quote No." := "Document No."; TempILE."Item No." := ILE."Item No."; TempILE."Variant Code" := ILE."Variant Code"; TempILE."Location Code" := ILE."Location Code"; TempILE."Unit Cost" := UnitCost; TempILE."Qty. Available" := QtyAvailable; TempILE."Qty. Total" := QtyTotal; TempILE.Quantity := ILE.Quantity; TempILE."Remaining Quantity" := ILE."Remaining Quantity"; TempILE.INSERT; END ELSE BEGIN TempILE."Qty. Available" := TempILE."Qty. Available" + QtyAvailable; TempILE."Qty. Total" := TempILE."Qty. Total" + QtyTotal; TempILE.Quantity := TempILE.Quantity + ILE.Quantity; TempILE."Remaining Quantity" := TempILE."Remaining Quantity" + ILE."Remaining Quantity"; TempILE.MODIFY; END; UNTIL ILE.NEXT = 0;
Comments
2) The problem is in OnAfterGetRecord and OnAfterGetCurrRecord triggers - Because these triggers are called many times during displaying the data, you cannot modify any data from these triggers. You need to do it in another way. I think that in this way is better to refresh the data "on push" or update them in another way. Simple, you cannot use these triggers...
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Also, please don't use findfirst in a loop. Use findset if u know that there is a match of ~ 500 recs or find('-') but not findfrist
Regards
I have created a form with many subforms related to the item in the main form. All the subforms work except for one. This one has a temp table behind it that is an accumulation of item ledger entries summed by "Item No.", "Variant code", "Location code" and "Unit Cost". The subform actually populates correctly but every time I change item numbers in my main form I get a message saying "Temp Item Ledger Entry cannot be modified in this form". It does actually update it so I can't figure out why I'm getting this message. I have given the main form, subform and custom table all permissions for the table. This message looks just like the message you would see if you went directly into the item ledger entry table and tried to modify it.
The way I am populating this subform is to call a function in the subform from the OnAfterGetRecord of the main form. The subform does have the property SourceTableTemporary set to yes.
Main form:
Function in subform:
Any help would be appreciated.
Andy
:shock: :shock: :shock: :shock: :shock: :shock: :shock: :shock: :shock: :shock:
So you were doing a DELETEALL on a filtered range of the Item Ledger Entry from a form.
If so then please please please stop now and get some help form a more senior developer in your company. This is extraordinarily dangerous, if you did this successfully on the live syste, then the whole database would be destroyed and virtually unusable.
Phew, your comments looked like it started as a Temp var based on ILE and then you made it not temp.
regards
1. Your Table that u want to use do you have created --> OK
2. now you create a form based on this table where you want to see the datas --> OK
3. in this form u set the property "SourceTableTemporary" --> I belive that you don't do this
4. In this form, modifications are not allowed, so properties InsertAllowed, ModifyAllowed, DeleteAllowed = false --> I belive that you don't do this
5. U Create there a function to fill the form --> OK -> CreateSummary(Parameter)
6. Is CreateSummary() correct <---> mhm, no :-(
Example (simple)
Now, u create a subformcontrol on your mainform, set there the property SubFormID to your new subform id, and give that subform a name like ILESubForm.
At last, go to Form - OnAfterGetCurrRecord() of the mainform and write this 2 little lines.
So, your are finished. test it, enjoy it <-- i have not test it, and the code here is based on my brain (no NAV here to test)
This little example works only for ITEMS :!: So, modify these codesnippes that it works also when a sales line is emty or the type is <> item.
Regards