June 28, 201213 yr hi, I wanted to create a script to update the stock value of the product. Here is the scenario. I have the 4 tables. Product (Stores the stock value and other product information) Purchase(My Product Purchases and total amount) Purchase_Detail(How many product i have bought and at what QTY) Stock(Keep track of the product purchase and sales) I have created portal in Purchase layout for Purchase Detail that allows me to input products i have bought and there QTY. I have setted the script trigger(Oncommit) on this portal. So, as i leave this portal the script triggers and it should update my stock in Product table and put a record in Stock table of what i have purchased. But the script i made cannot find the record in the product table. here is what i have written in the script. "Go to layout["Product"(Product)] Perform Quick Find[Purchase Detail::_fkProductID::Product Barcode] {Calculation in this step"Purchase Detail::_fkProductID = Product::Product Barcode"} Insert Calculated Result[select;Product::ProductInStock; Product::ProductInStock+Purchase Detail::Quantity]"
June 28, 201213 yr Once you go off to the Product layout, how is the script to know which purchase detail record you were on? That's what appears to be the problem. Try something like: // grab the info you need BEFORE you leave the portal row Set Variable[ $id ; Purchase Detail::_fkProductID ] Set Variable[ $qty ; Purchase Detail::Quantity ] Go to layout["Product"(Product)] Perform Quick Find[$id ] Set Field[ Product::ProductInStock; Product::ProductInStock + $qty ]
June 28, 201213 yr Author It worked like a charm thanks. But it i want to put in a check that as i try to press the tab it again triggers the same script for and empty row. How to handle that?
June 29, 201213 yr Not sure I'm understanding you completely, but after you set the $id variable, you could do: If[ IsEmpty( $id ) ] Exit script End If
June 29, 201213 yr Author Thanks. It worked fine. Can we insert a new record in a another layout with script?
June 29, 201213 yr Yes, use the New Record/Request script step (it's called that because it behaves differently in Browse vs. Find mode).
Create an account or sign in to comment