From a Workflow Action, how can I update a row with values from a SPECIFIC row in another table?

I have an app that includes minimal management of Inventory. For example, Purchase Orders (PO) can be added to show the quantity of an item that is โ€œOn Orderโ€. When the PO is received, a โ€œReceivedโ€ button is tapped that sets a โ€œReceived?โ€ flag and then a Workflow processes the items in that PO to move the counts from โ€œOn Orderโ€ to โ€œOn Handโ€.

In order to update the Inventory table based on the items in the PO, I collect the โ€œProduct Codeโ€ of the PO items and use that list to update the associated Inventory rows. When updating the Inventory row, I select the PO Item rows based on that โ€œProduct Codeโ€, SUM the values and update the โ€œOn Orderโ€ count. This works fine when there is only a single โ€œPO Itemโ€ row with that โ€œProduct Codeโ€.

The problem is when a product is on multiple POโ€™s (to be received on different dates). When updating the Inventory row, I need to select the โ€œPO Itemโ€ row for the specific PO that was just received. By the time processing has drilled into the Actions structure to where the Inventory row is being updated, the information of which PO was being processed is lost.

One approach I have considered, is adding a flag column that indicates which rows should be selected with the SELECT() statement from โ€œPO Itemsโ€ when updating the Inventory table values. This means I would need to set the flag at the start of the Workflow, process the marked rows and then clear the flag. This seems overly complicated but maybe the only approach I have available.

In this use case, instead of using a data flag, what is the best approach to be able to select the โ€œPO Itemโ€ row from a specific PO? Am I missing some feature that would help in this scenario?

0 12 1,728
12 REPLIES 12

I did solve my issue by setting a flag, โ€œProcess?โ€, to indicate a record that needs processed to update Inventory counts. The flag was added at the โ€œPurchase Orderโ€ level since this is where I indicate when an order is received. In the depths of the Workflow processing on each PO Item, I can still see if it is a record that needs applied by inspecting the โ€œPO IDโ€.โ€œProcess?โ€ flag.

This processing structure is needed in several places in my app and I am certain I am not the only one who has needed this type of processing. Maybe I am severely overlooking a feature to help with this??

If not, and there is no easier way to achieve this kind of calculation, then maybe we need to add another Action feature to help simplify this?

We have โ€œadd a new row to another table using values from this rowโ€. Maybe we also need โ€œupdate a row in another table using values from this rowโ€?

Should you structure/update work if only the last PO is used? Or could you built it in a way that when the PO is updated to your inventore table, you mark that row as โ€œDoneโ€?

I may have not been clear on the structure. I have a Parent/Child relation be tween PO and PO Item. The Inventory codes are part of the PO Item record. But any particular code could be part of any of several different POโ€™s.

When a PO is received and updates to Inventory are needed, I need to be able to clearly identify which PO Item records (for the same code) I need to update the Inventory records from. This means I need to โ€œmarkโ€ them somehow BEFORE the processing begins.

I tried creating a grouped action on Save to mark the PO Items but the Workflow is triggered before this group completes. Having a step in the Workflow to mark them at the start doesnโ€™t work either - it seems the data updates from previous Workflow steps are not available to subsequent steps?

In the end I marked the Parent PO record with Process? flag at the same time I marked it as Received?. I can later inspect the Process? flag through the Parent/Child relationship when updating the Inventory records and selecting the PO Item records.

This seems it is probably a very common construct needed in many different apps - update a value in another row based on values from the current row. In fact I have seen many questions around this over the past couple years.

If there is a better way to do itโ€ฆIโ€™m all ears!!

Soโ€ฆ you want to update the inventory records that belongs to PO as a child records, correct?

If I understand your question then yes you are correct. I want to update the Inventory record from the child records of the PO - these are the PO Item records. PO Itemโ€™s contain the Product Code and Quantity needed to update Inventory.

It sounds doable with actions and without flags. Let me checkโ€ฆ

Now when Iโ€™m thinking this little more, it sounds itโ€™s only doable if you count the total from PO Item records. You can write that value when the PO Item is saved with an Event action. The problem with this method is that if you want to remove the history, the inventory value is then wrong when you next time add a new PO Item. If you can keep all records in the app, then it might work. If you need to use security filter so it would be light to open, you should use sheetformula for that calculation.

Yes I think we are on the same page. Please donโ€™t spend any more time on it if you have other more pressing matters. I do have a working solution. Just always looking for a better, simpler approach.

It might have been lost in the thread that what I am doing is tracking the โ€œOn Orderโ€ items first - this shows what number is expecting to be received. Once the PO is received then I โ€œmoveโ€ that count from โ€œOn Orderโ€ to โ€œOn Handโ€ where โ€œOn Handโ€ is the current number physically available in Inventory. This is where I need to identify the specific PO Items because at any given time the โ€œOn Orderโ€ number could be a sum from several different PO Items received at different times.

In AppSheet, I think using flags is the only way we have of handling this type of processing because we currently do not have the capability to perform data updates operating on 2 specific rows without performing a SELECT() first.

This is why I was suggesting a new Action type like โ€œupdate a row in another table using values from this rowโ€. The โ€œrow in another tableโ€ is selected by some join like [_THISROW].[Product Code] = [Product Code]. This would help cut down on the number of Action blocks and eliminate the need for a โ€œselectionโ€ flag. Iโ€™ll open a feature request for this soon.

In my app I have Products and Materials that I am tracking incoming numbers (Purchase Orders) and outgoing numbers (Work Orders). There are several similar workflows creating a stack of Action blocks. But just imagine when I start tackling Corrections and Cancellations that require adjustments to the Inventory numbers! Fun, fun, fun!!!

In a โ€œpaperโ€ this could work but there is always a problem if two or more users are doing this at the same time. If you first need to read the existing value and then add some values into itโ€ฆ the last one wins. Thatโ€™s why itโ€™s better approach to calcluate the inventory value with the virtual column (or with the spreadsheet formula if filtering is needed).

Agreed. And I do filter and sum all โ€œactiveโ€ records for the โ€œOn Orderโ€ count. But I donโ€™t think this is feasible for the โ€œOn Handโ€ count. Too much history and too many moving parts go into that number.

Wait! Can I change a value in the Inventory record with a Virtual column on a Purchase Order record?

Yes you can if you know what record to read.

I will know by the Product Code selected. What is the statement used to perform the update? And I presume this will physically occur on the Save?

Top Labels in this Space