Working with Collections

Started by kkosienski, November 29, 2023, 18:16:17 PM

Previous topic - Next topic

kkosienski

I'm trying to write a script that will result in a collection containing a filtered set of elements. I'm looking to only include elements that contain a specific property name and value. I further want to filter the list of elements by the folder they reside in. Actually, I want to exclude elements that reside in two specific folders in my model tree. So show me all elements in the model with a specific property and value that do not reside in folder A or folder B.  The properties filter is pretty straight forward but I am not sure how to incorporate the folder check into a script. Any thoughts or suggestions are welcome! Thx.

Phil Beauvoir

This will return a collection of elements that are not members of folders called "Applications" and "Processes":

var collection = $('element').filter(function(element) {
    var folder = $(element).parent().first();
    return folder.name != "Applications" && folder.name != "Processes";
})
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Jean-Baptiste Sarrodie

If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

kkosienski

Thank you for the suggestions and code sample.

-Kevin