I would like to reference all nested instance managers for a given repeat within a parent instance manager. The way I have done this is to iterate thru an array of fields that exist inside all created nested instances and then identify each unique IM by using the _imid property. This works but I'm not sure how reliable it is. The code looks like this:

var i, g, PassengerIMs = [], prev;
for (i=0; i<{Gender}.length; i++) {
  g = sfc.findInstanceManager({Gender}[i]);
  if (g._imid != prev) {
  prev = g._imid;

One assumption here is that the Gender fields are returned in order.

In case it isn't clear we are representing multiple vehicles where each vehicle may contain multiple passengers.

Alternatively,I can get an array of nodes that represent the nested instance managers however this array refers to the html element that is the delegate of the instance manager and not the instance manager itself. Is there a way to derive the instance manager from this delegate or another way to solve this?



    CommentAdd your comment...

    1 answer


      To avoid the ordering issues and references to internal object properties, I would recommend object comparison using 'indexOf' instead:


      var instMgr, instMgrs = [];
      for (var i = 0; i < {Gender}.length; i++) {
            instMgr = sfc.findInstanceManager({Gender}[i]);
            if (instMgrs.indexOf(instMgr) === -1) {



      1. Matthew White

        It's worth noting that indexOf will not work on Arrays in Adobe Livecycle or on IE < 9. MDN provides a shim but that probably won't help in LiveCycle either as I don't think you can augment built in prototypes - you could call it directly though. Do you know if there is a way to get an instanceManager from the htmlElement that represents the instance?

      2. Jye Cusch

        Thanks for the compatibility info, that's important. As for instanceManagers, you can replace the {Gender} array of nodes, with the array of nodes that represent the nested repeating blocks and you should get the same result.

      3. Matthew White

        I mentioned that scenario in my original post - doing so only provides an array of the html divs that represent the instance managers not the instance managers themselves, hence the question.

      4. Jye Cusch

        That's true, but then you use sfc.findInstanceManager on the HTML node.

      5. Matthew White

        When I call sfc.findInstanceManager on each HTML node I get a reference to the outer instance manager not the inner ones: {Inner}.forEach(function (n) { console.log(sfc.findInstanceManager(n)) }) where {Inner} is an array of nodes referencing the inner instance Manager. For each node, sfc.findInstanceManager returns a reference to the same our instanceManager.

      CommentAdd your comment...