Method Community

 

Looping through a grid and updating a table for checked rows only

Last post 01-30-2014 4:40 PM by Method_Adam. 11 replies.
Page 1 of 1 (12 items)
Sort Posts: Previous Next
  • 01-24-2014 2:46 PM

    Looping through a grid and updating a table for checked rows only

    I have a grid based on the Contacts table. and one of the columns is a Yes/No field called "Dormant".

    I would like to check certain rows in the grid and then update those fields in the Contacts table using buttons. Let's say I have 2 buttons called "Make Dormant" and "Make Active".

    So...Let's say I have a grid filter at the top called "Dormant" that is showing want to check 20 total dormant contacts, and I want to make 10 of them active. In other words, I'd like to check 10 rows in the grid and then press the "Make Dormant" button - thereby updating the "Dormant" field in the Contacts table to "TRUE". for those checked rows.

    I imagine the first action associated with the "Make Dormant" button would be Loop through grid, using the "Checked rows only" option. I'm forced to choose a condition for this so I guess I could specify that the "Dormant" field is "FALSE", but that's really redundant anyway, because I have filters for the grid for "Dormant", "Active" and "All Customers". But regardless, I can't loop through the grid without specifying something, so that's tolerable.

    Anyway, what next? I'd like to use the Update field in table action, within the Loop through grid action, but all that does is update all 20 customers., and not just the checked rows. This is because the update field in table option does not allow me to specify to update only the checked rows. I thought that looping through the table, checked rows only would take care of that, but it doesn't.

    How do I structure this? It seems like it would be easy to do...


  • 01-24-2014 4:35 PM In reply to

    • fran
    • Top 25 Contributor
    • Joined on 02-08-2009
    • Mountain View
    • Posts 453

    Re: Looping through a grid and updating a table for checed rows only

    Mike,

    On the Loop through grid action - first screen - there is a "checked "rows only action...make sure its checked.

    Fran Reed
    FreedUp Solutions
    Intuit Solution Provider
    Advanced Certified Quickbooks ProAdvisor
    Advanced Method Solution Provider
  • 01-27-2014 6:48 AM In reply to

    Re: Looping through a grid and updating a table for checed rows only

    Fran - Thanks for the help!

    Hi Mike,

    As Fran said, make sure the "Checked rows only" option is checked. This way you are only looping through the checked rows you want to make dormant.  Then, make sure that your "Update field in table" action is inside your loop. When inside the loop, you can set the Where clause to update the field by recordID getting "Value from row" which would be the row of the grid.

    Hope this helps,

    - Adam

    Adam Lyons
    Manager of Support
    Method Integration
    a.lyons@method.me
  • 01-27-2014 11:54 AM In reply to

    Re: Looping through a grid and updating a table for checed rows only

    OK, that works, but now I have another issue:

    The grid I'm looping through is based on the Contacts table and is filtered to show "parent" entries only (ie. ParentFullname = blank). What I'd like to do is loop through the checked rows in the grid and update the following:

    • The parent entry
    • All subaccounts where the subaccount in the Customer table has a ParentFullname that is the same as the value from row.

    Do I need nested loops here? One that looops through the grid (checked rows) and within that a loop through the customer table?

  • 01-28-2014 1:04 PM In reply to

    Re: Looping through a grid and updating a table for checed rows only

    I'm receiving errors doing these actions that apply to a single row in the grid:

    • Loop through checked rows only (1 name)
    • Update the IsDormant field in the Customer table to "FALSE" where FullName = the Customer Name field from the contacts grid on the screen. This in theory takes care of the "parent" account"
    • Update the IsDormant field in the Customer table to "FALSE" where ParentFullName = the Customer Name field from the contacts grid on the screen. This in theory takes care of the subaccounts.
    • End loop through grid.
    But I'm getting action sequence error 2 saying that Is Dormant cannot be updated in the table.
  • 01-28-2014 1:37 PM In reply to

    Re: Looping through a grid and updating a table for checed rows only

    I changed the coding above so that the IsDormant field in the Customer table updates to "FALSE" when the FullName field = Value from row.FullName. This seems to work for the parent entries.

    The problem I have is the subaccounts. My coding says, make the IsDormant field in the Customer table "FALSE" when the ParentFullName field = Value from Screen Contacts.Customer Name. I get an error here saying: "

    An error has occured in the Update Field In Table action. Please verify all data being entered is correct.

  • 01-28-2014 2:32 PM In reply to

    Re: Looping through a grid and updating a table for checed rows only

    Hi Mike,

    May I suggest a different condition for your subaccount update? Could you not set the condition as (assuming this is the contacts table) "where parentFullName equals value from row FullName"?  Just include FullName field in the grid. You can then use that value to first update the parent, and then update the sub account by setting the where clause to find the parentFullName.

    - Adam

    Adam Lyons
    Manager of Support
    Method Integration
    a.lyons@method.me
  • 01-28-2014 2:35 PM In reply to

    Re: Looping through a grid and updating a table for checed rows only

    That doesn't work. Same error.

    Do I need to loop through the grid and then loop through the customer table? Or just loop through the grid?

  • 01-28-2014 2:43 PM In reply to

    Re: Looping through a grid and updating a table for checed rows only

    Mike,

    Give me some time to test out a few things. There should be a way to avoid using a nested loop.

    - Adam

    Adam Lyons
    Manager of Support
    Method Integration
    a.lyons@method.me
  • 01-29-2014 4:57 PM In reply to

    Re: Looping through a grid and updating a table for checed rows only

    Hi Mike,

    I found two ways around this. One way is to use "value from row" EntityRecordID.  The other is to use the Assign Value to Action Result at the top of the loop and assign it the FullName field from the row. I'm not sure why the action result works instead of just using the FullName but it does. Its likely something to do with how the value is cast, as parentFullName is looking for an integer value instead of a text value.

    Can you try either of these out and let me know?

    - Adam

    Adam Lyons
    Manager of Support
    Method Integration
    a.lyons@method.me
  • 01-30-2014 9:10 AM In reply to

    Re: Looping through a grid and updating a table for checed rows only

    It works, but...in the end it's a bit confusing.

    Just to reiterate, the grid is based on the Contacts table and is filtered so that it hshows only "parent" names (ie. ParentFullName is empty). Anyway, to update the "dormant" status of the Parent records in the Customer table, the only thing that works is FullName = ValueFromRow.FullName. But to update the subaccounts, I have to use ParentFullname = ValueFromRow.Entity_RecordID. Very strange. But they both work now...

    One more thing: I had to apply a filter to the grid where SpecialType = Contact, so that I did not get multiple entries of the same FullName with a blank ParentFullName for the particular customer I was testing. Unbeknownst to me, one was a Contact and one was an AltContact. What is an AltContact? It seems to be only in the Contacts table.

    Thanks

  • 01-30-2014 4:40 PM In reply to

    Re: Looping through a grid and updating a table for checed rows only

    Mike,

    The AltContact is the alternate QuickBooks contact. We sync this contact and obviously the main contact. Newer versions of QuickBooks have the ability to create more than two contacts, but Method can only sync to the main and alternate contact.

    - Adam

    Adam Lyons
    Manager of Support
    Method Integration
    a.lyons@method.me
Page 1 of 1 (12 items)