below is my code.
handlers.checkVersion = function (args1, args2, context) { var oldQABuildVersion = Number(args1.oldTestBuildVersion); var officialBuildVersion = Number(args2.recentBuildVersion); var testVersion = server.GetTitleData({Keys : ["OldTestBuildVersion"]})["Data"]["OldTestBuildVersion"]; if (testVersion.hasOwnProperty["OldTestBuildVersion"]) { testVersion["OldTestBuildVersion"] = oldQABuildVersion; } var buildVersion = server.GetTitleData({Keys : ["NewTestBuildVersion"]})["Data"]["NewTestBuildVersion"]; if (buildVersion.hasOwnProperty["NewTestBuildVersion"]) { buildVersion["NewTestBuildVersion"] = officialBuildVersion; } var setTitleDataRequest = { "Key": "OldTestBuildVersion", "Value": oldQABuildVersion, "Key" : "NewTestBuildVersion", "Value": officialBuildVersion }; var setTitleDataResponse = server.SetTitleData(setTitleDataRequest); // get the key var getTitleDataRequest ={ "Keys": ["OldTestBuildVersion"], "Keys": ["NewTestBuildVersion"] }; var getTitleDataResponse = server.GetTitleData(getTitleDataRequest); if (!getTitleDataResponse.Data.hasOwnProperty("OldTestBuildVersion" || !getTitleDataResponse.Data.hasOwnProperty("NewTestBuildVersion"))) { log.error("key not found. Exiting..."); return JSON.stringify([]); } else { return [getTitleDataResponse.Data.OldTestBuildVersion, getTitleDataResponse.Data.NewTestBuildVersion]; } };
I'm trying to return multiple keys. When I return single key - getTitleDataResponse.Data.OldTestBuildVersion - I get correct value. My Title Data doesn't get deleted, everything is fine. When I try to return multiple values like above, I get following error:
{"APIRequestsIssued":2,"Error":{"Error":"JavascriptException","Message":"JavascriptException","StackTrace":"TypeError: Cannot read property 'hasOwnProperty' of undefined\n at handlers.checkVersion (25E64-main.js:72:22)\n at Object.invokeFunction (Script:116:33)"},"ExecutionTimeSeconds":0.0211434,"FunctionName":"checkVersion","FunctionResult":null,"FunctionResultTooLarge":null,"HttpRequestsIssued":0,"Logs":[],"LogsTooLarge":null,"MemoryConsumedBytes":31008,"ProcessorTimeSeconds":0,"Revision":42,"Request":{"FunctionName":"checkVersion","FunctionParameter":{"oldTestBuildVersion":0.019999999999999997,"recentBuildVersion":"0.03"},"GeneratePlayStreamEvent":true,"RevisionSelection":null,"SpecificRevision":null,"AuthenticationContext":null},"CustomData":null}
so I checked my Title Data kvp, and found out that my key - NewTestBuildVersion - got removed when I called the function.
What's causing my key to be removed and how can I receive two values?
Following is my c# script for callback on this:
private static void OnCloudHelloWorld(ExecuteCloudScriptResult result) { // Cloud Script returns arbitrary results, so you have to evaluate them one step and one parameter at a time Debug.Log(JsonWrapper.SerializeObject(result.FunctionResult)); }