Get the group id from the name

Hello,
I am using the function a! groupsByName ("nameGroup") to get the id from the name of a group but the result returns us
[Group: 123] and I have to do the treatment to get the 123.

toInteger(
substitute(
split(
"[Group: 123]",
":"
)[2],
"]",
""
)
)

Do you know if there is any more direct way to get it?

thank you

  Discussion posts and replies are publicly visible

Parents
  • If you call tointeger() on a string, it will automatically strip out everything from the string that isn't a number and return the resulting integer.  And in this case, I think the type returned is actually "group type", which you can just call toInteger on itself - either way, you should probably be able to do what you were originally trying to do with a lot less fuss.

    tointeger(a!groupsByName("myGroupName"))

    Just keep in mind that if there's ever any possibility that 2 groups have the same name, a!groupsByName() will return an array.

Reply
  • If you call tointeger() on a string, it will automatically strip out everything from the string that isn't a number and return the resulting integer.  And in this case, I think the type returned is actually "group type", which you can just call toInteger on itself - either way, you should probably be able to do what you were originally trying to do with a lot less fuss.

    tointeger(a!groupsByName("myGroupName"))

    Just keep in mind that if there's ever any possibility that 2 groups have the same name, a!groupsByName() will return an array.

Children