0 Replies Latest reply: Dec 1, 2016 1:39 PM by Francis Kabinoff RSS

    Keeping selections in lists that use the same field but different expressions in sync

    Francis Kabinoff

      So say I create 2 lists, each using a different expression, as below

      app.createList({
        "qDef": {
          "qFieldDefs": ["=if([Name]='NameOfProduct', [Tags])"],
        },
        "qShowAlternatives": true,
        "qInitialDataFetch": [{
          "qHeight": 1000,
          "qWidth": 1
        }]
      });
      
      
      app.createList({
        "qDef": {
          "qFieldDefs": ["=if([Product Type]='TypeOfProduct', [Tags])"],
        },
        "qShowAlternatives": true,
        "qInitialDataFetch": [{
          "qHeight": 1000,
          "qWidth": 1
        }]
      });
      

       

      If I then make selections using the Field API on the "Tags" field, the above lists will get excluded values, but not selected, alternate, or selected-excluded values since they are seen by the engine as a different field than the "Tags" field.

       

      I know I can select within the model of each object itself with a bit of help from the Engine API, so I tried that

      app.createList({
        "qDef": {
          "qFieldDefs": ["=if([Name]='NameOfProduct', [Tags])"],
        },
        "qShowAlternatives": true,
        "qInitialDataFetch": [{
          "qHeight": 1000,
          "qWidth": 1
        }]
      }).then(function(model) {
        var msg = {"method":"SelectListObjectValues","handle":model.handle,"params":["/qListObjectDef",[0],true], "jsonrpc":"2.0"}
        model.session.rpc(msg);
      });
      
      
      
      app.createList({
        "qDef": {
          "qFieldDefs": ["=if([Product Type]='TypeOfProduct', [Tags])"],
        },
        "qShowAlternatives": true,
        "qInitialDataFetch": [{
          "qHeight": 1000,
          "qWidth": 1
        }]
      }).then(function(model) {
        var msg = {"method":"SelectListObjectValues","handle":model.handle,"params":["/qListObjectDef",[0],true], "jsonrpc":"2.0"}
        model.session.rpc(msg);
      });
      
      

       

      And this works fine. It will select the element with element number equal to 0 in each list, and the lists will represent state correctly.

       

      The problem is, I need to keep these two lists in sync. Meaning, if theres a tag called "Electronics" and I select that tag from the UI of either of these lists, then I need that selection to be made in both lists. But I can't simply select on the field, because the lists won't have the right states, and the element numbers are different for each list, so the element number for "Electronics", for instance, would be different in each list, so I can't simply have one method that selects on both models the same element number.

       

      Does anyone have any idea how I could meet the requirements of being able to have two different lists like above, both based on the same field, but using different expressions to limit that field, and having selections in either list update the states correctly for both lists?