How do I get only the additional data associated with a particular score on the leaderboard?

0 votes
I'm saving the game difficulty along with each score in the leaderboard:
scoreBoardService.addJSONObject(leaderboardName, {difficulty: "expert"});
scoreBoardService.saveUserScore(leaderboardName, userName, score, callback);   
The game is a played a few times and userName saves a few scores to the leaderboard service with the additional data.
The problem comes when retrieving the leaderboard with these calls:
scoreBoardService.setQuery(leaderboardName, null);  
scoreBoardService.getTopNRankersByDate(leaderboardName, startDate, endDate, 100, callback);   
The scoreList in the JSON response looks like this:
"scoreList": [{
   "facebookArrayList": null,
   "createdOn": "Thu Jun 2 07:55:38 GMT-0600 2016",
   "scoreId": "_v3OrvR34G9qMazm0pOArtpy10vM+I=",
   "docId": null,
   "userName": "JackTrash",
   "value": 280,
   "updatedAt": null,
   "event": null,
   "jsonDoc": null,
   "rank": null,
   "createdAt": null,
   "jsonDocList": [{
      "owner": "JackTrash",
      "updatedAt": "Thu Jun 2 07:55:38 GMT-0600 2016",
      "event": null,
      "jsonDoc": "{\"difficulty\":\"normal\",\"_$scoreId\":\"_v3OrvR34G9qMazm0pOArtpy10vM+I=\"}",
      "docId": "57503adae4b015974823fe8b",
      "createdAt": "Thu Jun 2 07:55:38 GMT-0600 2016",
      "loc": null
      "owner": "JackTrash",
      "updatedAt": "Thu Jun 2 08:07:57 GMT-0600 2016",
      "event": null,
      "jsonDoc": "{\"difficulty\":\"hard\",\"_$scoreId\":\"_v3bbwayk6GOVw5PaLScWiisqkZZU=\"}",
      "docId": "57503dbde4b0220cfa7f2a9b",
      "createdAt": "Thu Jun 2 08:07:57 GMT-0600 2016",
      "loc": null
   "owner": null,
   "loc": null
My question is around the jsonDocList.  It appears to contain a document for every score saved by the user JackTrash (2 in this case) - even though only one of the documents relates to the score returned by getTopNRankersByDate().
Is there a way to limit the jsonDocList to only return the document saved with that particular score?  
The concern is that if my top 100 players of the game have played a 100 games each - this call to get the leaderboard is going to be HUGE - with each of the 100 players having 100 JSON docs attached to their score.
Thanks for the help!
asked Jun 2, 2016 in Flash by justin.mette (10 points)

1 Answer

0 votes

Hi Justin,


You can easily resolve and get the latest JSON saved along with score by calling the below code:

var otherMetaHeaders:Dictionary = new Dictionary();
otherMetaHeaders["isAttachScoreId"] = "true"

Please call the above code snippet before fetching the leaderboard and let us know if it helps. 


HImanshu Sharma

answered Jun 2, 2016 by hs00105 (2,005 points)
That worked great.  Thank you!
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on