Method Community

 

Creating a relationship between items in different tables

Last post 10-04-2008 3:43 PM by Method_Paul. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 10-03-2008 5:20 PM

    Creating a relationship between items in different tables

    Need:

    Ability to capture extra data with an invoice from a grid. Similar to what is done in a standard invoice with the InvoiceLineItems grid in which the invoice screen uses the invoice table but also inserts records into the InvoiceLine table and creates a relationship between the records in the two tables so that when the invoice is viewed the line items show up. I need to add a section to capture line items for different information that I would like to store with the invoice.

    I added fields to reference the customer name and the invoice number. I made them required fields.

    When I try to insert the new record into my new grid I get the following error message:

    You are attempting to insert a record that is missing a required field. Ask your administrator to look at your table in the table and fields section of Method Integration and verify all required fields are listed in the grid.

  • 10-04-2008 3:43 PM In reply to

    Re: Creating a relationship between items in different tables

    Hi there.  Val and Kris won't be in the office until Monday, so perhaps I can help.

    From what I understand, you have a child table (we'll call "InvoiceOtherDetail") and a parent table (Invoice).  What you want to do is put a grid on the screen for this child table so that when you are creating an invoice you can also put info into InvoiceOtherDetail and have it automatically relate to that invoice.

    They key thing to realise with Method when it comes to relationships is that they are formed by creating a dropdown list field in the child table that references the parent field.  When that takes place, Method does all the heavy lifting from that point forward and figures out what you want to do.

    So do this:

    1. Go to Customize > Tables / Fields.

    2. Click on InvoiceOtherDetail (or whatever it is really called in your situation).

    3. Add a new field, of type Dropdown.

    4. For the table, choose an existing table, and choose Invoice.

    5. For the field, it's best to choose RecordID.  There really isn't anything unique about an Invoice other than the RecordID, since even the RefNumber can be duplicated, or left empty. 

    6. Now go to Customize > Screens.

    7. Click on the invoice screen to edit it.

    8. Drag a grid object from the toolbox on the left over to the screen on the right.

    9. Click Edit on the grid object.

    10. Choose an "Attached Grid", and choose InvoiceOtherDetail.

    11. Go through all the steps of the wizard, adding columns, choosing sorting, allowing edits and adds, etc.

    12. Publish your screen. You should be good to go now.  When you make a new entry into your grid it will automatically know that it is a child of Invoice and will put the reference in for you and relate it automatically to your invoice.

    Hope that helps,

    Paul

    P.S. If you don't mind.......let me know what you are building, and I might have some tips for you.

Page 1 of 1 (2 items)