Groups as triggeringItem & "triggeringGroup".member.forEach

i have several groups that are member of another group and some Items:

Group MainGroup
Group subGroup1 (MainGroup)
Item SomeItem1 (subGroup1)
Item SomeItem2 (subGroup1)
Group subGroup2 (MainGroup)
Item SomeItem3 (subGroup2)
Item SomeItem4 (subGroup2)

i would like to send a command to each member of a “subgroup”:

rule "myRule"
    Member of MainGroup received command DOWN
    triggeringItem.members.forEach (i | {
     do stuff
     do some more stuff  

visual code gives me this error for “members”:
The method or field members is undefined for the type GenericItem

is there a way to define the triggeringItem as a group?

Your first step might be to find out if triggeringItem is what you think it is, i.e. actually a Group type.
Log out its name.

I think that’s just the validator complaining though, won’t affect the function.

logInfo("Raffstore:", )

gives the correct group item

after that the rules fails:

Script execution of rule with UID 'sepia-2' failed: 'members' is not a member of org.openhab.core.items.Item'; line 23, column 5, length 22 in sepi

when i saved the rule i got this:

2022-06-05 12:24:22.172 [INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'sepia.rules', using it anyway:
There is no context to infer the closure's argument types from. Consider typing the arguments or put the closures into a typed context.

Well, the Message states GenericItem, I’m not sute about, but maybe try

(triggeringItem as GroupItem).members.forEach (i | {

Of course you should do a test if triggeringItem is of type GroupItem (i.e. there is a Group Item with the same name)

as GroupItem was the missing clue! Thank you!

You’re welcome.