Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Update stock with script

Featured Replies

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

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 ]

  • 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?

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

If[ IsEmpty( $id ) ]

Exit script

End If

  • Author

Thanks. It worked fine. Can we insert a new record in a another layout with script?

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

  • Author

Thanks. It worked fine.

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.