[Bug] MNI with Remove Group Members and a!groupsByName failing

I have a list of group names to remove from a user:

pv!toRemove = { "PROFILE 1", "PROFILE 2", "PROFILE 3" }

And the following Process:

The MNI for the Remove Group Members is configured as follows:

As node input, I have to provide the users and the group to remove.

  • For the user I'm simply using touser and providing it the username.
  • For the group I was using a!groupsByName(index(pv!toRemove, tp!instanceindex))

The problem is that the function a!groupsByName returns a list of groups and the input expects only one group. Even if the list has only one item, as the type is wrong, it will fail.

It will run the first instance and remove the "PROFILE_1" group, but the subsequent instances will fail because it tries to remove "PROFILE_1" again as the variable will not update anymore.


To fix this, we just need to make the return of a!groupsByName return a single group, I'm using index to achieve this:
=index(a!groupsByName(index(pv!toRemove, tp!instanceindex)), 1, null)

A suggestion, maybe this can be changed to match some other functions in Appian that when you send a list with only one element it runs normally, or to make it fail quicker in the very first instance and return a better error message.
Just sharing for improvement.

Have a great day there.

  Discussion posts and replies are publicly visible