The Second Image...
Script specifies that you want to delete the matching records - having same values of OrderNo, ProductCode and Qty in both tables, from OnOrder table. In order to achieve this, change the relationship - set the relationship on basis of three fields - OrderNo, Itemcode (ProductNo) and itemQty (ProductQty) of two tables (SRVOrder and ONOrder).
here is pseudo code of script
Go To Layout SRV Order
Go to first record
Delete all records
Go To layout SRV ORDER
Go To Record Request Page [Next,exit after last]
Your script has a number of problems.
Your Go TO Related Records step will leave you on the wrong layout if there are no related records and then your delete records might delete them from the wrong table. You should always check for the existance of related records just before the GTRR step or for an error code immediately after the GTRR step to properly handle situations where there are no related records.
Get (lasterror) as written, will never return an error. Get (LastError) must be used immediately after the step that might generate the error for which you are testing. As written, Get (LastError) would return an error only if the IF step immediately above it generated an error.
It's not clear to me exactly what you are trying to do. Do you want to delete records from SRV Order or OnOrder? I'd guess you want to delete from OnOrder.
What is the purpose of these two tables? It's a bit unusual to have so many fields in both tables with exactly the same information. Usually, it's better to put that data in only one table and use the relationship to refer to it from the other, but this also requires a proper primary key to foreign key relationship to make that work.
Hi, Thks for the response.
My point is to delete the record on ONOrder table, when its match with the 3 related condition, else has to reduce the Qty in OnOrder Qty.
If SrvOrNo = OrderNo
IF SRVItem = Onorder
If Srv Itemqty = Onorder Qty
Delete record in Onorder Table,
OnorderQty = Onorderqty-SrvQty
I want to have this kind of script.
The problem is that you may have many records in OnOrder that match to the Current record in Srv Order and your If steps only refer to the first such related record. Your comparisons need to be made from the context of OnOrder, not Srv Order.
If [Not IsEmpty ( ONOrder::Order_No) ]
Go To Related Records
//Then check the other two values now that you are "on" the OnOrder table instead of Srv Order