question

contrejo27 avatar image
contrejo27 asked

ListGroupMembers not returning last member.

I'm wondering why ListGroupMembers is missing the last member in the group. It shows me the first 2 but it doesn't find the last. Which is the player I'm looking for with playerID;

function setMatchName(tournamentEntity, playerID)
{
        var matchName =  -1;


    //get member index for current player from member list
    var apiResult =  entity.ListGroupMembers({
            Group:  tournamentEntity.Group,
        });
        
        var index =0;
    for(var member of apiResult.Members){
                      log.debug("Member " + member.Members[index].Key.Id + "compare with " + playerID);


          if(member.Members[index].Key.Id == playerID){


              matchName = index;
          }
index++;
        
    }


    return matchName;
}
CloudScriptentities
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Seth Du avatar image
Seth Du answered

apiResult.Members in your code is a list of Roles, which contains members of each role inside. Hence, you are always iterating the first member of each role. Please refer to the below sample code to get ID.

for(var role of apiResult.Members){
    for (var member of role.Members) {
        log.info(member.Key.Id);
    }
    
}

We highly recommend using RESTful testing tools like Postman to learn callback structure of an API, you may also find more details in specific API document -- Groups - List Group Members - REST API (PlayFab Groups) | Microsoft Docs

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.