Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 4526 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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]"

Posted

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 ]

Posted

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?

Posted

Not sure I'm understanding you completely, but after you set the $id variable, you could do:

If[ IsEmpty( $id ) ]

Exit script

End If

Posted

Yes, use the New Record/Request script step (it's called that because it behaves differently in Browse vs. Find mode).

This topic is 4526 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.