I make the API call as normal to CloudScript, then in the handler I do this:
var GrantItems = server.GrantItemsToUser({ "PlayFabId": currentPlayerId, "ItemIds": jsonData.hull, });
I get a proper response back from the Script as shown below, but when I try to access the data via:
GrantItems.ItemGrantResults.ItemInstanceId or GrantItems["ItemGrantResults"]["ItemInstanceId"]
I'm getting an error, it returns undefined or null
"PlayFabId": "EC8A1047D88320F1", "Result": true, "ItemId": "20001", "ItemInstanceId": "1893B3CF8363B827", "ItemClass": "hulls", "PurchaseDate": "2016-09-07T16:34:40.493Z", "Annotation": "Item granted by Admin", "CatalogVersion": "main", "DisplayName": "Mauser Gunboat Mk 1", "UnitPrice": 0
Answer by willwhittaker · Sep 07, 2016 at 04:47 PM
Never mind, didn't realize that the result from GrantItemsToUsers returned as an array.
Correct, the ItemIds returned is the array of all items added, so that you have the ItemInstanceIds and all the info on the specific items added. For titles using random result tables ("drop tables"), this can be particularly important, so that you can present information about the item(s) received to the player.
Update Cloud Script limits? 1 Answer
Getting ItemInstanceId from GrantItemsToUser,Returning ItemInstanceId from GrantItemToUser 1 Answer
How many external servers can connect to playfab using the secret token? 1 Answer
Cloud Script Logs - Server/Events Only (don't send to client) 1 Answer
grant multiple itmes 3 Answers