4 Replies Latest reply on Apr 26, 2012 3:01 AM by bnmohr

    Two related popup menus, second one shows record ID after changing first popup

    Erik,

      Title

      Two related popup menus, second one shows record ID after changing first popup

      Post

      Hi,

      We have three tables. 'Category', 'Subcategory' and 'Product', all records have a primary key (auto number). Subcategory has a foreign key to the primary key of Category. Product has foreign keys to both Category and Subcategory (we need only the foreign key to Subcategory but need the Category for the value list).

      We want to index products by Category and Subcategory. So, when adding a product to the Product table, you first select from a popup menu the right category and then from a second popup menu the subcategory. We solved this with setting the relations and creating two conditional value lists. We use the primary keys of the Category and Subcategory and display the names (use as second field) in the popup menu's. Subcategory is filtered by the selected Category via the Product layout.

      Problem: after changing a category, the displayed name of the previous subcategory is changed by its primary key value, after clicking the popup menu of subcategories, the right subcategories are displayed and after selecting the new subcategory, the name is correctly displayed in the popup menu. 

      Question: is there a way (by scripting) to clear text in the popup menu (when not clicked) of the subcategory after changing the category? Or a solution to show the first item of the new filtered subcategories?

      Thanks,

      Erik de Vries

        • 1. Re: Two related popup menus, second one shows record ID after changing first popup
          aammondd

          You can use an OnObjectSave(or Exit)[you can even use on OnObjectModify as you are using a popup/dropdown list] script trigger to Set Field for the Subcategory field  to "" You could even add a Show Custom Dialog box with a single button reminding them to set a new subcategory.

          You could encapsulate this logic in an If[] script step to check to see a subcategory had already been selected so that it doesnt do anything if it hasnt been set.

          You could then setup validation rules to ensure that a new value is entered into the field.

          • 2. Re: Two related popup menus, second one shows record ID after changing first popup
            philmodjunk

            A simple script performed via an OnObjectModify script trigger set up on the Category Pop up menu should do the trick:

            Set Field [Product::SubCategory ; "" ]

            This can also be made selective so that the field is cleared only if the current value is not a member of the current subCategory value list:

            Set Field [ Product::SubCategory ; If ( IsEmpty ( FilterValues ( ValueListItems ( get ( FileName ) ; "SubCategory value list name in quotes" ) ; Product::Subcategory ) ) ; "" ; Product::SubCategory ) ]

            • 3. Re: Two related popup menus, second one shows record ID after changing first popup
              Erik,

              Hi Aammon/PhilModjunk,

              Thanks for your fast replies, it works like expected.

              Erik

              • 4. Re: Two related popup menus, second one shows record ID after changing first popup
                bnmohr

                I'm trying to do the same thing as far as categories, and I have a working system, it just doesn't seem to be very elegant, if anyone wanted to comment on this I would appreciate it... I definitely follow along with the OP as far as needing another table occurance to filter the sub category value list (devices for value list) when adding new device (product).

                However, my question is then how do you choose a product (device in my case) from another table, in my case signals.  So I'm on a Signal layout, I have popup menues for category, sub category and device with value lists of sub categories and devices populated as seen from the signal table occurances, is this the simplist method?  It seems like a lot of extra table occurances and I don't know if it costs anything in database size or processing.  Many thanks in advance,

                 

                Brian