So I made a simple CloudScript method to get User ReadOnly Data:
handlers.CheckQuestsDate = function(args) { var result = server.GetUserReadOnlyData({"PlayFabId" : currentPlayerId, "Keys" : ["QuestList"]}); log.info(result); var questObject = JSON.parse(result.Data["QuestList"].Value); var LastTimeCompleted = Date.parse(questObject.playerQuestList[0].timeWasActivated); var DaysSinceLastCompletion = CalculateDayDifference(LastTimeCompleted, Date.now()); var retObj = {}; if (DaysSinceLastCompletion <= 1) { retObj["Success"] = true; }else { retObj["Success"] = false; } return retObj; };
When I execute ExecuteCloudScript with the "Try it" button with the function name = "CheckQuestsDate" as parameter, I get :
{ "code": 200, "status": "OK", "data": { "FunctionName": "CheckQuestsDate", "Revision": 43, "Logs": [ { "Level": "Info", "Message": "{\"PlayFabId\":\"12BA3CBC081A2BC1\",\"DataVersion\":0,\"Data\":{}}" } ], "ExecutionTimeSeconds": 0.0363576, "ProcessorTimeSeconds": 0, "MemoryConsumedBytes": 49152, "APIRequestsIssued": 1, "HttpRequestsIssued": 0, "Error": { "Error": "JavascriptException", "Message": "JavascriptException", "StackTrace": "TypeError: Cannot read property 'Value' of undefined\n at handlers.CheckQuestsDate (FB3E-main.js:303:56)" } }, "CallBackTimeMS": 415 }
As you can see, the Data field is empty (and can´t get the Value field in my method so I get theTypeError). However when I use GetUserReadOnlyData with the sample request "Try it" button with Keys = QuestList and PlayFabId = AB006BF1C23FFA63 as parameters I get this:
{ "code": 200, "status": "OK", "data": { "PlayFabId": "AB006BF1C23FFA63", "DataVersion": 636, "Data": { "QuestList": { "Value": "{\"playerQuestList\":[{\"id\":8,\"currentProgress\":0,\"timeWasActivated\":\"Wed, 13 Jun 2018 20:46:50 GMT\"},{\"id\":1,\"currentProgress\":0,\"timeWasActivated\":\"Wed, 13 Jun 2018 20:46:50 GMT\"},{\"id\":6,\"currentProgress\":0,\"timeWasActivated\":\"Wed, 13 Jun 2018 20:46:50 GMT\"}]}", "LastUpdated": "2018-06-13T20:46:50.356Z", "Permission": "Private" } } }, "CallBackTimeMS": 562 }
You can see that data is not empty. I need this data to compare Dates, however it´s always empty any help is welcome, thanks!