i have products table and purchases table
in products table i have stock field and i added an action under products table
Action Name: Increase Stock After Purchase
For a record of this table: Products
Do this: data set the values of some columns in this row
set these columns: Stock: i added the below expression
[Stock] + IF(
ISNOTBLANK(SUM(SELECT(Purchases[Quantity],
AND([Product] = [_THISROW].[Product],
[Stock Updated] = False)))),
SUM(SELECT(Purchases[Quantity],
AND([Product] = [_THISROW].[Product],
[Stock Updated] = False))),
0
)
in purchases table i have two actions
Action 1 Name: Set StockUpdated Flag After Purchase
For a record of this table: Purchases
Do this: data set the values of some columns in this row
set these columns: Stock Updated: Yes
Action 2 Name: Update Stock After Purchase
For a record of this table: Purchases
Do this: data execute an action on a set of rows
referenced table: Products
Referenced Rows: LIST([Product])
Referenced Action: Increase Stock after purchase
i also created a bot
Purchase Event
event Source: App
Table: Purchases
Data Change Type: All
in Run this process i added a new step
Increase Stock Task
I Choose Run a data action and i choose update stock after purchase
then i added a new step Change Stock Updated to True
i choose Run a data action and choose
Set StockUpdated Flag After Purchase
when i create a new purchase the action of changing the Stock Updated from false to true is working but the action to increase the stock doesnt work i remove the Set StockUpdated Flag After Purchase from the bot and after adding a new purchase also nothing is happened but if i go to products page and click manually on the actionthe stock increased
i changed the above expression to [Stock] + 1 and keep the Set StockUpdated Flag After Purchase in the bot everything is working the value changed to true and the stock is increased by 1 so any help to check where is my mistake
Instead of select()'ing across the entire purchases table, I suggest utilizing the [Related Purchases] VC.
Another thing to try would be to utilize input() for this action chain to send in the purchase qty to the product's update action, instead of using select() at all. You'd need another real column on the product table to temporarily hold the value from input().
User | Count |
---|---|
16 | |
8 | |
7 | |
3 | |
2 |