question

Arif Sefa avatar image
Arif Sefa asked

Update user data over 10

I'm intializing player data on cloud script when player newly created. But I can't type over 10 area inside of KVP datapayload. I split one payload to two but that means 2 times player update call on server and it's kind of bad even api call and performance. Wha is the best way to do this?

I used:

    var dataPayload = {};
    dataPayload["Key1"] = "Value1";
    dataPayload["Key2"] = "Value2";
    dataPayload["Key3"] = "Value3";
    dataPayload["Key4"] = "Value4";
    dataPayload["Key5"] = "Value5";
    dataPayload["Key6"] = "Value6";
    dataPayload["Key7"] = "Value7";
    dataPayload["Key8"] = "Value8";
    dataPayload["Key9"] = "Value9";
    dataPayload["Key10"] = "Value10";
    dataPayload["Key11"] = "Value11"; // when after added this key func. retuning null.



    server.UpdateUserData({
        PlayFabId: currentPlayerId,
        Data: dataPayload
    });


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

·
Citrus Yan avatar image
Citrus Yan answered

The number of player data key/value pairs which may be updated in a single request is limited to 10 by default. And, as a matter of fact, a large number of small keys being modified at once is far less efficient than a small number of larger keys, therefore, you may consider combing those keys into a/few larger keys to avoid this error.

2 comments
10 |1200

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

Arif Sefa avatar image Arif Sefa commented ·

So do you suggest something like this?

dataPayload["Key1"]="Value1/Value2/Value3";

After want to use inside code split all of them and assign to place. Am I correct?

0 Likes 0 ·
Citrus Yan avatar image Citrus Yan Arif Sefa commented ·

I would suggest the following:

handlers.test = function (args, context){
     var dataPayload = {}
     var values = {
         Key1: "Value1",
         Key2: "Value2"
         //...
     }
     dataPayload["Keys"] = JSON.stringify(values)


    server.UpdateUserData({
        PlayFabId: currentPlayerId,
        Data: dataPayload
    });
}

Storing the value as a JSON object, making it convenient for you to access its data later.

0 Likes 0 ·

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.