0

Constrain to 'any' of a multi choice

Hi, I'm trying to constrain the selection of products to those with 1 or more matching labels.

So for example : Label like Label Choices

Although with this, I only get products with exactly the same Label Choices, so i.e. If the Label Choices are "Red", "Handle", "Discounted" - I will only see products with all 3 labels. How do I constrain to see any one of these choices?

3 replies

null
    • Sean
    • 5 yrs ago
    • Reported - view

    Are you using a View layout element to display the records or using the built-in filter on the column header? I can get this to work in a View layout element...

     

    let myArray := ["Red", "Blue"];
    (select Table2)[contains(concat(chosen(MC2)), item(myArray, 0)) or contains(concat(chosen(MC2)), item(myArray, 1))]

     

    The problem is the constraint is not dynamic, but I can't devote anymore time on it right now. Some takeaways are...

    -Use "or" to separate the constraints

    -Use chosen() to get the selected values of a Multiple Choice field

    -chosen() returns an array and that's why I used concat() to convert it to a string and then use contains()

    • Sean
    • 5 yrs ago
    • Reported - view

    This example is still using the View layout element...

     

    Screen Shot 2019-02-12 at 1.08.23 PM

     

    Screen Shot 2019-02-12 at 1.08.50 PM

     

    Screen Shot 2019-02-12 at 1.09.16 PM

     

    It uses a Multiple Choice field in Table1, selects the matching records in Table2 and displays the results in a View layout element. This is the code in the View's formula...

     

    let myArray := chosen('MC Table1');
    (select Table2)[contains(concat(chosen('MC Table2')), item(myArray, 0)) or contains(concat(chosen('MC Table2')), item(myArray, 1)) or contains(concat(chosen('MC Table2')), item(myArray, 2)) or contains(concat(chosen('MC Table2')), item(myArray, 3)) or contains(concat(chosen('MC Table2')), item(myArray, 4)) or contains(concat(chosen('MC Table2')), item(myArray, 5))]

    • Richard_B
    • 5 yrs ago
    • Reported - view

    A lot for me to divulge! Thanks. I am using the built in filter I think, so I am adding a New Product to a Purchase Order from a table of products, I get the pop out view of all my products when adding a new product to the PO, which is what I am trying to pre-filter the view of based on selected criteria of the particular Client the PO is based on.

    I'll have a play with some of the above and see how I get on, thanks again

Content aside

  • 5 yrs agoLast active
  • 3Replies
  • 2031Views