Help with formula to update an invoice log from a table view using a button

This one has got me stumped.

I have an INVOICE PAGE where I have a table view filtered for items selected for a particular order. Once the invoice is sent, I have a button that adds that invoice to an INVOICE LOG. This basically copies the data into a new table so any future changes to item prices do not affect the invoice amount.

I’m able to do that with no problem. My problem arises when the customer decides to make changes to the invoice (reduce price for item a, remove xyz items). When a change occurs in my filtered INVOICE PAGE, a button tracks when a change happens and gives me the option to “UPDATE invoice”.

Check code below that shows the logic.
The issue is when I’m clicking on UPDATE, it changes ALL the items with that order ID to the last item in the filtered view table on INVOICE PAGE.

What I want to only change the item that was updated.

Can you please help me!? I’ve been stuck on this on so long and it’s draining me :frowning:

'
"this formula is found in the ADD TO INVOICE/UPDATE INVOICE button"

RunActions(
  If([invoice log].[invoice ID_ invoice log].Contains([order ID select]),

"if order ID exists, do this"

"this ifTrue is what I'm not able to do."
|
|
|






"else do this"
"this ifFalse bit works when you're logging that invoice for the first time"
,
    
  ([Balance due].FormulaMap(
    AddOrModifyRows(
      [invoice log],[invoice ID_ invoice log]=[order ID select],
     
      [invoice ID_ invoice log],[order ID select],
 
      [customer_ invoice log],customer_select_invoice,
      
      [SKU_ invoice log],SKU,
      [items  _ invoice log],Items,
      [weight_ invoice log],weight,
      [Qt_ invoice log],Qt,
      [order type_ invoice log],[order type],
      [no. of items_ invoice log],[no. of items],
      [unit price_ invoice log],[unit price],
      [total price_ invoice log],[total price],
      [unit price_ invoice log],[unit price],
      [discounted unit price_ invoice log],[discounted unit price],
      [discounted price_ invoice log],[discounted price]
      ) "end of AddOrModifyRows"
    ) "end of formula map"
  ) "end of ifFalse"
) "end of if",
  

"this is a helper that changes my button to UPDATE when last date modified changed"
  [invoice modified helper].AddOrModifyRows(
    [order ID] = [order ID select], 
    [invoice modified helper].[order ID], [order ID select],
    [last modified],[helper last modified]
  )
)

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.