Issues with multiple checkboxes

Hi All,

I am facing Issue With More than two selection of Checkboxes.
I am attaching the requirement document.
Thanks

More than two selection Checkbox.doc

OriginalPostID-221397

OriginalPostID-221397

  Discussion posts and replies are publicly visible

  • Hi ramesh
    Create Different constants for individual conditions which you want to show and under chocieValues{} and choiceLables use all the constant under if() based on condition show the values which u want.
    To hide the above check box when below check box is selected based on the stored value of above check box hide the below check box field.
  • @rameshm Please find attached the code snippet and it gives an idea of how the usecase can be accomplished.

    And I would like to suggest you to store the combinations in a database table. And a simple query with type of entity (Exchange US/Exchange UK), entity id or entity value (id or value of the chosen Exchange US/Exchange UK) as query filters should drive the classes. Though this functionality is doable by using functions such as if(),choose(),displayvalue() and combinations thereby, it's always worth storing the combinations in a database entity as this leads us to drive the results in a simple manner rather than checking loads of conditions. Also storing the matrix in database makes the maintenance simple as compared to maintaining the same in expression rules.
  • 0
    Certified Senior Developer
    I support the suggestion given Sikhi. It is important to maintain the relationship in database. As CME is a growing organisation, you would need a solution which would fit in the future needs of the client.
    I would suggest to have 3 different ref tables.
    1. To save the Exchange type (CMEEL, CEMCE, CBOT, CME, COMEX, NYMEX)
    2. To save all possible Classes (Agricultural, Energy, etc).
    3. The relationship between the two tables: For each row in exchange type.

    Now if the user selects two exchange types from one region, then have the union of all possible classes and display them. And you will be able to store the class id for the application.
    This structure will support if there are any addition of classes in future for any exchange type(s).

    In addition to that, I would suggest to ask user for the UK / US exchange using a dropdown or radio option so that it would save your extra effort of hiding the irrelevant exchange types.
  • @Sikhivahans,
    Thanks, It's working fine.
    But, I am facing a small issue I.e., in a rule while selecting it is capturing the Exchange US where as while calling that rule in interface it is not capturing the Exchange US in the PV.


    Thanks
  • Hi Sikhi,

    I agree with the answer. I have a similar use case I am implementing. do you still have the snippet available?
  • Ramesh, I see a solution has already been provided/discussed but here's one I played around with earlier this morning. 

    Here's an image and code attachment you can test out. 

    The idea here is to have a row for each exchange that has its own set of classes that will be indexed into based on the index position that comes back from using wherecontains() against a constant of exchanges. Afterwards, remove duplicates and use the unique set for your checkbox. 

    Note: If any of the classes were to ever contain a comma in their name, then obviously, the code would not work.

    Picture

    Code 

    load(
      /*ri!exchanges = values that would come from your checkboxField*/
      
      /*If you stored your exchanges in a constant*/
      local!exchangeConstant:{"CMEEL", "CMECE", "CBOT", "OTHER"},
      
      /*Pull the index position of your exchange choices*/
      local!exchangeIndexes:wherecontains(ri!exchanges, local!exchangeConstant),
      
      /*What classes each exchange currently have*/
      local!classes:
      {
        "Agricultural, Energy, Foreign Exchange",  /* CMEEL */
        "Agricultural, Energy, Foreign Exchange",  /* CMECE */
        "Agricultural, Energy, Foreign Exchange",  /* CBOT */
        "Agricultural, Equity, Interest Rates"     /* OTHER */
      }, 
    
      /*Pulls which rows of classes to retrieve based on Exchange Indexes*/
      local!classIndexes:apply(
        index(local!classes, _, {}), 
        {local!exchangeIndexes}
        ), 
      
      /*Splits result from local!classIndexes into multiple text values (for checkbox purposes) */  
      local!splitIndexes:split(local!classIndexes, ","), 
      
      /*Removes duplicates*/
      local!removedDuplicates:union(local!splitIndexes, local!splitIndexes), 
      
      local!removedDuplicates
        
    )