question

Kim YongSik avatar image
Kim YongSik asked

UpdateUserInventoryItemCustomData Question

handlers.itemCustomDataUpdate = function(args, context) {
    var stat = {
        "Grade": args.itemGrade,
        "Level": args.Level,
        "Upgrade": args.Upgrade
    };
    var request ={
        "ItemInstanceId": args.ItemInstanceId,
        "PlayfabId": currentPlayerId,
        "Data":{stat}
    };
    log.info("itemGrade " + args.itemGrade);
    log.info("Level " + args.Level);
    log.info("Upgrade " + args.Upgrade);
    var result = server.UpdateUserInventoryItemCustomData(request);
    return result;
};
PlayFabClientAPI.ExecuteCloudScript(new ExecuteCloudScriptRequest()
                {
                    FunctionName = "itemCustomDataUpdate",
                    FunctionParameter = new { itemGrade = 1, Level = 1, Upgrade = 1, ItemInstanceId = item.ItemInstanceId },
                    GeneratePlayStreamEvent = true,
                }, (csresult) =>
                {
                }
                , OnPlayFabError);
{
    "EventName": "player_executed_cloudscript",
    "Source": "CloudScript",
    "FunctionName": "itemCustomDataUpdate",
    "CloudScriptExecutionResult": {
        "FunctionName": "itemCustomDataUpdate",
        "Revision": 20,
        "FunctionResult": {},
        "FunctionResultTooLarge": null,
        "Logs": [
            {
                "Level": "Info",
                "Message": "itemGrade 1",
                "Data": null
            },
            {
                "Level": "Info",
                "Message": "Level 1",
                "Data": null
            },
            {
                "Level": "Info",
                "Message": "Upgrade 1",
                "Data": null
            }
        ],
        "LogsTooLarge": null,
        "ExecutionTimeSeconds": 0.0370663,
        "ProcessorTimeSeconds": 0.001421,
        "MemoryConsumedBytes": 5872,
        "APIRequestsIssued": 1,
        "HttpRequestsIssued": 0,
        "Error": null
    },
    "EventNamespace": "com.playfab",
    "EntityType": "player",
    "TitleId": "F9156",
    "EntityId": "C68C2843E544CBBE",
    "EventId": "b72dff2d7897415c8c6d24ef86d8248e",
    "SourceType": "BackEnd",
    "Timestamp": "2022-03-23T08:48:13.0743852Z",
    "History": null,
    "CustomTags": null,
    "Reserved": null,
    "PlayFabEnvironment": {
        "Vertical": "master",
        "Cloud": "main",
        "Application": "logicserver",
        "Commit": "6550575"
    }
}

Run in unity.I want to save three custom data but failed.

What did I do wrong?

The above three are / Cloud script / Unity script / PlayStream

aaaa.png (36.5 KiB)
zzzz.png (43.5 KiB)
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

·
Gosen Gao avatar image
Gosen Gao answered

After doing some tests, I found that the issue is caused by the Data parameter. Please replace the {stat} with stat and try again.

var request = {

	"ItemInstanceId": args.ItemInstanceId,

        "PlayfabId": currentPlayerId,

        "Data": stat

};
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.

Kim YongSik avatar image Kim YongSik commented ·

Thank you. It's resolved.

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.