Hello all,
I need your help again… I would like to have a telegram message sent to me, in which all open windows are listed.
I have so far the following:
sendTelegram("bot1", "Fenster " + gWindow.members.filter[i | i.state==OPEN] + " ist offen" )
Unfortunately, this way I get the group member with all properties (Type, State, Label, Category, etc.) displayed. I would prefer to have only the label displayed.
Since it can also happen that several items are OPEN, a listing of the labels (names) would be bursting.
Does anyone have experience? Would be very pleased.
Greetings
deibich
(David)
January 5, 2021, 2:09pm
2
Take a look at the “Tutorial & Examples” section. Your scenario is described there.
To build a String containing all the names of Items that are OPEN there are two approaches: use map/reduce or use a val StringBuilder.
// StringBuilder
val StringBuilder sb = new StringBuilder
MyGroup.members.filter[ i | i.state == OPEN].forEach[i | sb.append(", " + i.name) ]
// Map/Reduce
val str = MyGroup.members.filter[ i | i.state == OPEN ].map[ name ].reduce[ s, name | s + ", " + name ]
The StringBuild approach works because we can declare it as a val but still can call methods on it to change it.
1 Like
Thanks, that worked for me!
But do you know how to prevent the output NULL? Did not find anything for that.