Hi there. I’m working on a simplified ERP in Appsheet and struggling with a few of the automations. All problem automations have to do with setting a value in an existing row in Table A from a value in/form related to Table B. I saw this post, but the poster didn’t provide enough information for someone to suggest a solution. I’m hoping now there might be a solution to this, perhaps?
Setup:
- User creates a “job” in Appsheet by filling out a Create Job form. In that form, the user enters a numeric Estimated Material Use value (like “10,” as in pounds). If needed, the user can fill out a Cancel form afterward to represent “cancelling” the job in the real world. The Cancel form in Appsheet includes fields where the user can enter a Completion % value (as a whole number, like “50”) and Actual Used Material value (also a whole number like “20”).
- There are two tables: one for Jobs and one for Material Tracking. The Jobs table shows all jobs and their associated information, including values like Estimated and Actual Material Use. The Material Tracking table contains a list of all possible materials, all of which have unique IDs set by the app, and the total amount in stock for each material. The “Total In Stock” value for each material is the same format as the Estimated Material Use and Actual Material Used fields in the Jobs table (i.e., numeric value representing pounds).
Goal:
- When a user fills out the Cancel form to “cancel” a job, the system should calculate an updated value for the Total In Stock field in the Material Tracking table like this:
Total In Stock (new value) = Total In Stock (existing value) -
IF(
ISNOTBLANK(Jobs[Actual Material Used]),
Jobs[Actual Material Used],
Jobs[Estimate Material Use]
*
IF(
ISNOTBLANK(Jobs\[Completion %\]),
Jobs\[Completion %\] / 100,
1
)
)
The idea of this formula is: if there is a value in Actual Material Used (in the Jobs table), subtract that from the Total In Stock value in the Material Tracking table. If not, multiply the Estimate Material Use value by the Completion % value / 100 (if Completion % has a value in it; else multiply by 1) and subtract that from the Total In Stock value in the Material Tracking table instead. This calculation should not create a new row - it needs to edit the existing row for the material based on the unique material ID. New rows in the Material Tracking table are added manually via a different form in the app; it’s important for this decrementing calculation to edit the correct existing row for the material used in the job.
I’ve hit a lot of reference-related errors with functions like [_THISROW], [_THISROW-1], and wide-reaching functions like ANY() and SELECT(). Typically, the errors call out that the row I’m trying to set or reference is not in the table I’m currently editing.
Any and all suggestions appreciated. Just trying to get some accurate material quantity tracking going on over here. ![]()