question

Ethan K. G avatar image
Ethan K. G asked

CloudScript: GetObjects always return null

Try to call entity.GetObjects using the following three different ways, no error, but always return null. Any hint or suggestion?


Here is the source code:

// (1)
let goResult: PlayFabDataModels.GetObjectsResponse = entity.GetObjects({ Entity: { Id: [GroupID], Type: "group" } });

// (2)
let goResult: PlayFabDataModels.GetObjectsResponse = entity.GetObjects({ Entity: { Id: currentPlayerId, Type: "master_player_account" } });

// (3)
let goResult: PlayFabDataModels.GetObjectsResponse = entity.GetObjects({
    Entity: {
        Id: PlayFabIDToEntityID(currentPlayerId), Type: "title_player_account"
    }
});

// goResult always return {}
log.info("Group: " + psEvent["_GroupID"] + ", goResult: " + JSON.stringify(goResult.Objects));

CloudScriptentities
1 comment
10 |1200

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

Seth Du avatar image Seth Du ♦ commented ·

I cannot fully test the code but may I ask have you double-checked that the corresponding entities have been set Objects? It should be updated via SetObjects API.

If the entity doesn't have any objects, goResult.Objects should return "{}".

You may quickly set/get Objects via Restful testing tools(Postman).

0 Likes 0 ·
Seth Du avatar image
Seth Du answered

Yes, I have written a sample, and it works fine for me.

handlers.objTest= function(args, context) {
    var getTitleAccReq = 
            {
          "MasterPlayerAccountIds": [
            currentPlayerId
          ]
        };
        
    var getTitleAccResult = entity.GetTitlePlayersFromMasterPlayerAccountIds(getTitleAccReq);
        
    var GetObjectsReq = {
      "Entity": {
        "Id": getTitleAccResult.TitlePlayerAccounts[currentPlayerId].Id,
        "Type": "title_player_account",
        "TypeString": "title_player_account"
      }
    };

    var result = entity.GetObjects(GetObjectsReq);
    return result;
}

Feel free to let me know if you have any questions. I am using ExecuteCloudScript and if you use ExecuteEntityCloudScript API, you may get the title player account ID from "context" easily.

10 |1200

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

Ethan K. G avatar image
Ethan K. G answered

@SethDu, Thanks for your reply.

In fact, what I want to do is to read & write Groups Objects from CloudScript. Am I using correct API? Is there any sample code about this functionality?


10 |1200

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

Ethan K. G avatar image
Ethan K. G answered

Screenshot:


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.