question

willwhittaker avatar image
willwhittaker asked

GrantItemsTouser not letting me access ItemInstanceId?

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
CloudScript
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
willwhittaker avatar image
willwhittaker answered

Never mind, didn't realize that the result from GrantItemsToUsers returned as an array.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image brendan commented ·

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.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.