Microsoft Azure PlayFab logo
    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Add-ons
    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA
  • Runs on PlayFab
  • Pricing
    • Blog
    • Forums
    • Contact us
  • Sign up
  • Sign in
  • Ask a question
  • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges
  • Home /
  • API and SDK Questions /
avatar image
Question by willwhittaker · Sep 07, 2016 at 05:21 PM · CloudScript

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
Comment
Grzegorz

People who like this

1 Show 0
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by willwhittaker · Sep 07, 2016 at 04:47 PM

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

Comment

People who like this

0 Show 1 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Brendan ♦♦ · Sep 07, 2016 at 07:36 PM 0
Share

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.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Navigation

Spaces
  • General Discussion
  • API and SDK Questions
  • Feature Requests
  • PlayStream
  • Bugs
  • Add-on Marketplace
  • LiveOps
  • Follow this Question

    Answers Answers and Comments

    No one has followed this question yet.

    Related Questions

    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

    PlayFab

    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Runs on PlayFab
    • Pricing

    Solutions

    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA

    Engineers

    • Documentation
    • Quickstarts
    • API Reference
    • SDKs
    • Usage Limits

    Resources

    • Forums
    • Contact us
    • Blog
    • Service Health
    • Terms of Service
    • Attribution

    Follow us

    • Facebook
    • Twitter
    • LinkedIn
    • YouTube
    • Sitemap
    • Contact Microsoft
    • Privacy & cookies
    • Terms of use
    • Trademarks
    • Safety & eco
    • About our ads
    • © Microsoft 2020
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Create an article
    • Post an idea
    • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Explore
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges