Method Community

 

Updating fields in Customer table using selected rows in a grid

Last post 05-31-2013 3:28 PM by Anonymous. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 05-31-2013 1:47 PM

    Updating fields in Customer table using selected rows in a grid

    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:

    1. Loop through the grid for the checked cells
    2. Assign the record IDs of the checked rows to a field called "actionresultdeactivate". These are joined with a comma
    3. End loop
    4. 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"
    5. End loop

    My 2 main issues are:

    1. 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?
    2. 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
  • 05-31-2013 3:28 PM In reply to

    Re: Updating fields in Customer table using selected rows in a grid

    Answer

    Hi Mike,

    Based on your end goal, there is an easier approach for this. 

    You can do the following:

    (This solution assumes your records are based off the Customer table)

    1. Loop through the grid for checked cells
    2. Update IsActive value to False in Customer table where Customer Record ID equals value from row Record ID (the grid value’s Record ID)
    3. End Loop
    4. Refresh Grid

Page 1 of 1 (2 items)