Sign In Register

How can we help you today?

Start a new topic

Problem with Game Data Service

 

I really don't know am I doing something wrong here.
So, when I create new entry with this code:

var api = Spark.getGameDataService();
var entry = api.createItem("playerHeroes", "Testing");
var data = entry.getData();
data.testing = 100;
var value = data.testing;
Spark.setScriptData("valueOf", value);

It have no errors, and it returns the right value, but in this code:

var api = Spark.getGameDataService();
var entry = api.getItem("playerHeroes", "Testing");
var data = entry.document().getData();
var value = data.testing;
Spark.setScriptData("valueOf", value);

It throws an error on line 3 : can't call getData() of NULL. So, the problem is that it can not find entry with id "Testing".
But, once I manually insert entry with ID "Testing" the script above works as intended.

So, what am I doing wrong here?
Login to post a comment