On the Customer Edit screen of a "Parent" customer, we have a tab called subaccounts that shows the associated subaccounts for that parent. So, for company ABC, the subaccounts tab has a grid that has Main Account, Staff1, Staff2, etc. subaccounts shown in a grid (with checkboxes). For these subaccounts, I show various fields in the grid, including "IsActive?"
What I want is a "Deactivate" button that changes selected rows in the grid from TRUE to FALSE.
I assume I associate the following logic to the actions associated with the button:
- Loop through the grid for the checked cells
- Assign the record IDs of the checked rows to a field called "actionresultdeactivate". These are joined with a comma
- End loop
- Loop through the Customer table and update fields in the customer table where the record ID equals the "actionresultdeactivate" action result and change the "IsActive" field to "FALSE"
- End loop
My 2 main issues are:
- I can build the record ID list from checked rows, but there is a comma at the beginning of the list. How do I get rid of that or prevent it from happening? For example, if I select 2 subaccounts with Record IDs of 1234 and 5678, the "actionresultdeactivate" field is: ", 1234,5678". Does that even matter that the extra comma is there?
- I'm not sure I'm using the correct logic for updating the fields. I want to say "for every record in the actionresultdeactivate field, change the IsActive entry to false
This seems like a relatively simple thing to do and I feel I'm close, but some quidance is appreciated.
Thanks