Saving additional leaderboard info from custom code

0 votes

Now I'm trying to save additional LB info from custom code (JAVA). Problem is that we need to set DB name according to documentation, but we can't do this with static App42API.setDBName method (App42API methods are restricted in custom code). Another class with such method is Storage. But it seems that Storage is irrelevant to the LB service. So what is correct way to save additional LB info from custom code?

asked Nov 3, 2014 in App42 Cloud API-BaaS by zveroid (22 points)

1 Answer

+1 vote
Best answer

Hello Zveroid,

Kindly find the below code snippet to save the additional information of user through custom code:


JSONObject json = new JSONObject();

json.put("Name", "Nick");

json.put("Age", 25);

JSONObject credentials = new JSONObject();

credentials.put("dbName", "Your db name");

credentials.put("collectionName", "Your collection name");

otherMetaHeaders.put("jsonObject", json.toString());

otherMetaHeaders.put("dbCredentials", credentials.toString());

mScoreBoardService.setOtherMetaHeaders (otherMetaHeaders);

Game game = mScoreBoardService.saveUserScore(gameName,userName,gameScore); 


Also, please have a look on this link for fetching the information back into the app through custom code  and let us know if it helps.


Himanshu Sharma


answered Nov 4, 2014 by hs00105 (2,005 points)
selected Nov 6, 2014 by zveroid

Thanks, it really worked but only for saveUserScore method. Does some way to set/change additional info during score editing (editScoreValueById) exists? It seems that metaheaders didn't taken into account during score editing :(

Updating the additional info along with editSocreValueById method is not supported yet however you can update through storage service by using updateDocumentByKeyValue or AddOrUpdateKeys method. Please have a look at the below link & let me know if it helps.

Himanshu Sharma
Thanks, Himanshu!
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