Sum up values in repeater

In the attached example, I can assign a buyer to a slot by typing the slot number in the text field and click on the button.

When I click on the button the buyer will be assigned to the slot I provided.

If the slot is available i.e. “blank”, then the buyer is assigned to it together with its items.

However, if the slot is not “blank” i.e. there is a previous buyer assigned to it, then there are 2 cases:

1st case: if the slot I selected has already a buyer which is different from the buyer I selected for the slot, then there is a warning message to the user to overwrite the previous buyer and items with the new buyer and related items; (this is already working fine)

2nd case (for which I kindly ask for help): if the slot I selected has already a buyer which is THE SAME buyer I selected for the slot, then the number of items already there should be summed up with the new items for the same buyer. For example, the buyer B has 2 new items to allocate and I would like to assign the slot 2 to it which however has already 5 items assigned to Buyer B. Therefore, when I type slot 2 and click the button, the system should sum up 5+2 for the Buyer B in the slot 2. How can I sum this up? Besides, there should be a maximum of 150 items to assign to the same buyer hence when a Buyer hit this limit there should be a message to the user “not possible to assign any more items”.example2_solved.rp (149.5 KB)

See this updated file:
example2_solved.rp (189.9 KB)

As you now have two different message conditions to show, I changed the “warningmessage” from a Group to a Dynamic Panel, duplicated the state and changed the text and buttons. Now you can set the panel state with “show if hidden” to show the associated message dialog.

I moved the Set Variable Value actions to the BUTTON, so it is easier and more reliable to update things.

When ++NumSlot in AllocTable is moved, it now has 4 cases in this order:

  • Case 1, Same buyer, too many items
    • If this is the slot and buyers match and (current items + new items) is greater than 150
      • Set Panel State warningmessage to ‘Max Items’, show if hidden
  • Case 2, same buyer, update the count (of this row)
    • Else if this is the slot and buyers match
      • Update this row with by adding the value of the “colli” column (number of current items) and the “selectedcolli” global variable (number of new items): [[Item.colli + selectedcolli]]
  • Case 3, Different buyer and not empty
    • Else if this is the slot and the “handler” or “colli” columns have non-blank values
      • Set Panel State warningmessage to ‘Allocated’, show if hidden
  • Case 4, Empty row
    • Else if this is the slot
      • Fire Event BUTTON fire Moved (same as before)
1 Like

Thank you very much! It worked really well

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