Subform field "Price" calculated on every row

Subform field "Price" calculated on every row

I have a pricelist of items As in the screenshot



So the idea is to have function that is used when adding rows in a subform. The subform is pretty much a price calculator, that has 3 fields:

columnValue ( which is integer, 1,2,3..8), rowValue(also integer, 100,150,200..300), and Price (Which needs to be updated after entering the rowValue field.
  1. float pricePerItemCalculator(int columnValue, int rowValue)
  2. {
  3. Index = rowValue;
  4. priceList = {};
  5. if(columnValue == 100)
  6. {
  7. priceList = {100,6.93,7.44,7.95,8.42,8.93,9.45,9.96,10.47};
  8. Price = priceList.get(Index);
  9. }
  10. else if(columnValue == 150)
  11. {
  12. priceList = {150,8.47,8.96,9.45,9.96,10.47,10.96,11.47,11.9};
  13. Price = priceList.get(Index);
  14. }
  15. else if(columnValue == 200)
  16. {
  17. priceList = {200,9.98,10.47,10.98,11.47,11.98,12.47,12.98,13.49};
  18. Price = priceList.get(Index);
  19. }
  20. else if(columnValue == 250)
  21. {
  22. priceList = {250,11.34,11.84,12.35,12.86,13.35,13.86,14.38,14.8};
  23. Price = priceList.get(Index);
  24. }
  25. else if(columnValue == 300)
  26. {
  27. priceList = {300,12.74,13.25,13.76,14.25,14.74,15.22,15.25,16.27};
  28. Price = priceList.get(Index);
  29. }
  30.   else{
  31.     
  32.   }
  33.   return Price;
  34. }
Atm I am calling the function with a Workflow on user input of rowValue

  1. rowValue = input.Price_per_item.rowValue;
  2. columnValue= input.Price_per_item.columnValue;
  3. input.Price_per_item.Price = thisapp.pricePerItemCalculator(rowValue, columnValue);

The problem is that with this, I only get it working for the first row added in the subform. After that for the rest of the rows it doesn't update the Price field.

I also tried with row.Price_per_Item instead of input., which didn't help.