Beware of old data in loops
Connector loops and attribute-value loops modify some values in the work object each
time around the loop, but they do not reset the rest of the attributes to the value that they
entered the loop with. This means that values can be carried over from one entry to the
next if new values are not explicitly provided. This problem is particularly likely with
LDAP lookups, as when an LDAP attribute has no values it simply does not exist in the conn object.
Possible solutions:
- Careful use of the Null Behaviour options on input maps.
- Split out the body of the loop into a separate assembly line and call it with the AL Function Component, just passing in those attributes that it needs.
- Use a script to remove the unwanted attributes from the work object.
Here is a simple script that removes everything except the
thisMember attribute:
var thismem = work.getString("thisMember");
work.removeAllAttributes();
work.setAttribute("thisMember", thismem);
That is a bit wholesale, so it may be better to build something more targeted using
removeAttribute() or perhaps just copy the original work object and restore it each time around the loop.
--
AndrewFindlay - 17 Dec 2014