0

Button script to select/link record on child table

Using the Invoice Template, I have a the 'Invoice' Table with an embeded 'Invoice Items' table. I add items to 'Invoice Items' by selecting existing records previously input in the 'Article' table. This involves a number of selections: (1) + create record (below 'Invoice Items'), (2) on a popup blank table 'Invoice Item' select the "Search" icon (add existing record) and (3) select the record in the 'Article' table.

Instead I want simplify this with a button on the 'Invoice' table to popup the 'Article' table and select a record and link it to 'Invoice Items',  and lastly close the popup after the selection.

I've found a number of scripts that get close, but apparently get tied up on the table references. Three steps for each item becomes laborious when dealing with a 100+ Invoice Items. Any help is appreciated!

9 replies

null
    • Fred
    • 1 yr ago
    • Reported - view
     said:
    Three steps for each item becomes laborious when dealing with a 100+ Invoice Items. Any help is appreciated!

    Wow, those are really long invoices. I haven't seen a way to "popup" the reference field link.

    I'm not sure this a great way to input 100's of items, but I think you should look into a dashboard/page. It will allows you to select an Invoice (or create a new one), then with a dynamic multi choice field you can select multiple Articles and then with a click of a button you can add those items to the selected Invoice.

    The one issue is there is no way to add a different quantity to each article selected. You would have to go back and modify the quantity for each article.

    • bflack
    • 1 yr ago
    • Reported - view

    Apologies, a more accurate description of the task is to create a "Jewelry Line sheet" --that is, a wholesale listing of items with multiple variations, each with a different WS price. I agree that the dashboard approach would be ideal, but have read that the dynamic multi-choice field is limited to 100. As it now stands there are 193 items, likely to be 250+.

    Each item in a "Line Sheet" typically has a quantity of 1, but even then, changing quantities directly in the 'Invoice Items' table is easy.

    Thanks again for giving this some thought.  

    • Fred
    • 1 yr ago
    • Reported - view

    Take a look at this sample.

    Also, Ninox did away with the 100 choice limits for dynamic fields. I did a test of one with over 5,000 and it works fine.

    Just because we can do it doesn't make it useable. Trying to find a specific item amongst 190 or 250 choice is a chore. Maybe you can break it up into categories.

    But here is a start of how a dashboard would work. You can have two buttons or one button that changes code depending on if an invoice record is selected.

    • bflack
    • 1 yr ago
    • Reported - view

    Thanks. Looks promising as an approach. Good point that there should be small subgroups. I'll fiddle to see if I can get to work --but may need some help getting the code right. Will get back in a couple of days.

    • bflack
    • 1 yr ago
    • Reported - view

    Thanks to you, there has been much success. I've broken the list into 4 categories to make Product Selections, and added the buttons modeled from your example. As usual, some fiddling was needed to get the table references correct.

    The only step remaining: I could use some help with a button to select all from the dynamic multi choice fields (by sub-group) - and also clear selections. In addition to standard Invoices, I need to create a wholesale "Line Sheet" of all products, making for a lot of box checking and unchecking. I apologize for not being able to script something that may be obvious to those with more experience.

    Again, many thanks in advance! 

    • Fred
    • 1 yr ago
    • Reported - view
     said:
    The only step remaining: I could use some help with a button to select all from the dynamic multi choice fields (by sub-group) - and also clear selections.

    I was just going to mention that you should add a clear command at the beginning of your category buttons, so it will clear out any selections before you see the next grouping. I have the clear code in the Trigger of the other fields and at the end of the buttons.

    You can take the part of the category buttons where you get the filtered records

    let x := select Table1 where fieldx = subcategory
    

    Then you can set the dynamic field by:

    dynamicfield := x
    
    • bflack
    • 1 yr ago
    • Reported - view

    Many thanks. This evening I came up with my own buttons (perhaps not as elegant), using the choice field 4 subgroup options 'CollectionGroups':

    Select All Button
    -----------------
        switch CollectionGroups do
    case 1:
        'SelArtl-MH' := (select Article)
    case 2:
        'SelArtl-RH-RM' := (select Article)
    case 3:
        'SelArtl-LG-HR-EX' := (select Article)
    case 4:
        'SelArtl-MR-BP-DS-AR' := (select Article)
    default:
        null
    end

    Deselect All Button
    -------------------
    switch CollectionGroups do
    case 1:
        'SelArtl-MH' := null
    case 2:
        'SelArtl-RH-RM' := null
    case 3:
        'SelArtl-LG-HR-EX' := null
    case 4:
        'SelArtl-MR-BP-DS-AR' := null
    default:
        null
    end

    Many thanks for continuing support as I learn Ninox!

      • Fred
      • 1 yr ago
      • Reported - view

      You have four different dynamic choice fields? Why not just use one that changes based on the value of collectiongroup:

      let t := this;
      if t.collectiongroup = null then
      select Articles
      else
      select Articles where category = t.collectiongroup
      end
      
    • bflack
    • 1 yr ago
    • Reported - view

    Nice touch! I knew there was a more elegant approach.

    Thanks

Content aside

  • Status Answered
  • 1 yr agoLast active
  • 9Replies
  • 175Views
  • 2 Following