0

Button script to select all items in defined Dynamic Multiple Choice field

In a jewelry database, I have a series of Dynamic Multiple Choice fields to identify items and add them to orders/invoices. As an example:

  • Choose Items in Article table with Dynamic Multiple Choice Field ('selArtl-MH') using Choice Field "Collection" options: sort(select Article)[Collection = 3 or Collection = 18 or Collection = 19] order by colSortColl
  • Then choose all dMC items ('selArtl-MH' in Y/N check box mode) with a button script button script :
    'selArtl-MH' := (select Article)[Collection = 3 or Collection = 18 or Collection = 19]

While this works, seems klutzy, and more importantly, whenever the dMC selection criteria changes, the button script also needs changing, leading to mistakes with 6-8 dMCs to manage.

Ideally, the button script would reference the defined dMC field (rather than repeat that criteria) and then select all as 'Yes'.

Many thanks in advance for thoughts!

Bob

4 replies

null
    • Fred
    • 6 mths ago
    • Reported - view

    Is Article.Collection a dynamic field as well?

    Or

    You said there are 6 - 8 dynamic choice fields. Are you always looking for the same grouping of Collections? Is one group (3,18,19) and another could be (1,5) and another could be (5,9,10)? If so then you can create a choice field with 6 - 8 choices then in your select all button you can use a switch() command to set the dynamic choice to the group you want. If this new field is called 'Select Group':

    let getArticleRecs := select Articles
    'selArtl-MH' := switch 'Select Group' do
    case 1:
        getArticleRecs[Collection = 3 or Collection = 18 or Collection = 19]
    case 2:
        getArticleRecs[Collection = 1 or Collection = 5]
    case 3:
        etc
    end
    
    • bflack
    • 6 mths ago
    • Reported - view

    Hi Fred,

    Indeed, I use switch/case to select the dMC's, each with their own criteria --that works well. The Article.Collection is a straight choice field --assigning characteristics to each item for dMC selection criteria. Creating the dMC's with criteria is a great feature, but it turns out that the vendor changes the criteria for market reasons periodically, and then I need to chase those changes though, in this case, to the button scripting to 'select all'.

    Bob

    • Fred
    • 6 mths ago
    • Reported - view
     said:
    Creating the dMC's with criteria is a great feature, but it turns out that the vendor changes the criteria for market reasons periodically,

     So group1 which use to consist of 3,18,19 now will be 4,17,19 as an example?

    How often do these changes happen?

    Do you want a way to set these groups through a UI and then have it populate through to the dMC and the Select All button?

     said:
    Article.Collection is a straight choice field

     Maybe you want to create a table of the Collection options. Then you can have a field there that stores which group the collection is part of. Hopefully a collection can only part of a single group.

    Then you can change your code for the dynamic field and the select all to look at Collection.group instead of Collection.

    • bflack
    • 6 mths ago
    • Reported - view

    Some good thoughts. So far in a year there's been only one change, but it was a pain. I don't think it's worth creating a UL, but the notion of a making a table with the groups is interesting, usable for both the dMC and button script. Then editing only takes place in the table.

    I'll give that a shot.

    Thanks, Bob 

Content aside

  • 6 mths agoLast active
  • 4Replies
  • 62Views
  • 2 Following