I actually have a similar problem. I have a list of views in which I need to hide certain elements in specific views based on system abbreviation, and have previously gotten the code to work well for single views, but for sake of time, would like to run the script to hide these specific elements in the specified views with no user input. These views cannot be filtered because the views I need are all dependent views with view templates. From what I have, I need to run it for all system abbreviations on each of the matching views.
I’ve gotten a bit further, and I think I’m on the right path, but I can’t get it to fully function for all views passed in. I turned the above function into a node to simplify things, then I took all the system abbreviations and created a function with each of them being the only value for the string comparison. For the views, I placed all the filters I needed, then took the views I wanted for each system and placed them as an input to the function above. Thus far, the script works until I get to the above section. I’m not sure if the problem is with the multiple views, or the elements, but it will, at best, only work for a few of the views.
To conclude this, I found my issue was with lacing. All the nodes worked properly, with exception of a few string values improperly spelled (or attached to the wrong nodes). The “Service Hiding” nodes needed to have lacing set to cross-product, so they could evaluate more than the first node, and I had to adjust the custom node to more properly evaluate the terms.
NOTE: cross-product lacing is essentially the same (for my purposes) as running a loop.