Hi, I am currently working on a form that is based on the Item Unit of Measure table. On the “OnAfterGetRecord” trigger, I have two functions that will perform calculations for the records. The results of the calculations will only be displayed on the form, but will not be recorded to the table. I tried to use the “CurrForm.saverecord” after I called the two functions on the “OnAfterGetRecord” trigger, but it will give me an error message saying, “You can’t modify any records using this trigger.” I tried the other way, which is implementing “modify” function after entering values to the fields, and it will give me the same error message I got earlier. My coworker suggested me to put all the codes and functions within the “OnOpenForm” trigger, but it is impossible for me to do so, and by the way, I already have a function there that would filter all the markedonly records, based on the shipment date of all the sales orders, and there are some other criterias for this function to obtain certain records. I thought of performing this function, instead of before all the calculations are done, I do not know if it is alright to do this after the calculations. So far, I sort of tried the above methods, but they do not look like they are working (in other words, I no longer get all the calculated values right; although I still have all the functions remained the same.) Anyone can help me with this? Thanks in advance. Sincerely, Sylvia Tsang Management Software Solutions, Inc. firstname.lastname@example.org
My favorite methood is: 1. In source (from based rec) table add function ShowMyCalc():Decimal. In this func. you can use Rec as current record in form. 2. In from add control wiith source expresion ShowMyCalc() Advantege: Function is easy accessed from anywhere and easy to use. Do you assign your func. result to Rec field ?
Hi, I understand what you suggested. But I have another issues coming up, I have 3 shipment date flowfilters in the table. Each of them is correspond to the 3 Sales Lines’ flowfields that calculate the quantities of 3 different range of shipment dates. If I really am going to have all the functions in the table, I might have a difficult time calling them. Anyway, the answer to your question is: I assign all the functions’ results to the records’ fields. My main concern is for now, how do I deal with the flowfilters while implementing all the functions in the table? Thanks again. Sincerely, Sylvia Tsang Management Software Solutions, Inc. email@example.com
Flow filters don’t change anything, use CALCFIELDS for flow fields. If your rec have 3 flow fliters on Rec and 3 flow fields in this rec too, all that you need is CALCFIELD. If your Flow filters not in Rec, pass them as parameters of func.
Hi, I am not entirely sure what you are trying to do but if you want complete control over what is shown on a form the you should use a form based on temporary records … This can be achieved by putting code on the OnFindRecord and OnNextRecord triggers. It is hard to explain in the message how but if you want to see an example have a look at the Reserve form from Sales Order, Functions. You should try it. It is pretty fun
What I am trying to do here is run a form called Breakdown Statistics and all that would do is to show all the item unit of measure records that contain sales line’s order quantities (sales of current week, 1 week ago, and 2 weeks ago), and based on the results, the program can calculate the quantities they need in order to build the warehouse journal. I still couldn’t figure out how to get it done … I removed all the calculation functions from the form, and have them implemented to the table. In other words, I call these functions from the table. Still, it didn’t save the calculated results. Here are the codes that I got on the form on the “OnOpenForm” trigger: CalcAllQty(FromShipDate : Date) // find out which items will be involved (based on the input of shipment date … ) SETRANGE(“Shipment Date Filter”,TargetDate); OneWeekBeforeTarget := TargetDate - 7; SETFILTER(“Shipment Date Filter 1”,’%1’,OneWeekBeforeTarget); TwoWeeksBeforeTarget := TargetDate - 14; SETFILTER(“Shipment Date Filter 2”,’%1’,TwoWeeksBeforeTarget); IF FIND(’-’) THEN REPEAT IF “Case UOM” THEN BEGIN ItemUOM.SETRANGE(“Item No.”,“Item No.”); ItemUOM.SETRANGE(“Split UOM”,TRUE); IF ItemUOM.FIND(’-’) THEN BEGIN REPEAT ItemUOM.SETFILTER(“Shipment Date Filter”,’%1’,TargetDate); ItemUOM.SETFILTER(“Shipment Date Filter 1”,’%1’,OneWeekBeforeTarget); ItemUOM.SETFILTER(“Shipment Date Filter 2”,’%1’,TwoWeeksBeforeTarget); ItemUOM.CALCFIELDS(“Open Order Qty.”,“Close Order Qty. 1 Wk. Ago”,“Close Order Qty. 2 Wk. Ago”); IF (ItemUOM.“Close Order Qty. 1 Wk. Ago” <> 0) OR (ItemUOM.“Close Order Qty. 2 Wk. Ago” <> 0) THEN FoundRec := TRUE UNTIL (ItemUOM.NEXT =0) OR FoundRec; IF FoundRec THEN BEGIN MARK(TRUE); FoundRec := FALSE END END ELSE IF NOT FoundRec THEN BEGIN MARK(FALSE); FoundRec := FALSE END END ELSE IF “Split UOM” THEN BEGIN CALCFIELDS(“Open Order Qty.”,“Close Order Qty. 1 Wk. Ago”,“Close Order Qty. 2 Wk. Ago”); IF (“Close Order Qty. 1 Wk. Ago” <> 0) OR (“Close Order Qty. 2 Wk. Ago” <> 0) THEN MARK(TRUE) ELSE MARK(FALSE); END; UNTIL NEXT=0; MARKEDONLY(TRUE); The rest of the 2 calculation functions are being called on the “OnAfterGetRecord” trigger. Thanks. Sincerely, Sylvia Tsang Management Software Solutions, Inc. firstname.lastname@example.org