I'm trying to check which person to assign to each job using GAS. The function runs against an array that contains both: the person responsible for the client and his client list.

The code works fine when running for the first Client in the array, it adds the member and everything, so I know it's working. The problem is it only runs once, so if the client is "PR", it will add "lucasfogolin" as a member, but if its CLC, it won't check.

```
var clients = [{actor:'lucasfogolin',clients:'PR,CLC,Trívia,Smart,MC,TTWO'},
               {actor:'alfredorocha',clients:'FDV,IAB,IMDiva'}
              ]

```

My sorting function is below:

```
function sortActors(notification) {

  //When a card is moved to the "Sorting list"
  var card = new Notification(notification).movedCard('Sorting');

  //Gets the cards name
  var cardName = card.name();

  for (var i = 0; i < clients.length; i+=1) {

    //Creates an array from splitting the clients
    var arrayClients = clients[i].clients.split(',');

    for (var j = 0; j < arrayClients.length; j+=1) {

      //Creates a REGEX to run against the card's name, not sensitive
      var regex = new RegExp(arrayClients[j],'gi');

      //Checks if the name of the client is in the name of the card
      if(cardName.match(regex)[0] == arrayClients[j]) {

        //Function that adds the actor to the card
        addMembers(card,clients[i].actor)
      }
    }
  }
  return false;
}

```

addMembers function

```
function addMembers(card,members) {

  //Makes an array from the members cited (if more than one is to be added)
  var array = members.split(',');

  //Runs a loop to add all members
  for (var i = 0; i < array.length; i+=1) {
    card.addMember(new Member({username: array[i]}));
  }
}

```