question

ebrahimB avatar image
ebrahimB asked

Running into issues getting two of the recipes to work.

Hello,

I am trying to test out two of the recipes: Progressive rewards and referral codes.

Progressive Rewards: I am having issues with the cloud script. In the callback in my code, the result.FunctionResult returns null. I managed to get it working by changing the return from

return grantedItems;

to this

return {result: grantedItems};

With that, the cloud script returns a value I can work with but I am not sure if that is a bug or if I was doing something wrong.

Referral Codes: I again am having issues with the cloud script. I did the same edits as above to get the cloudscript to return a list of items instead of null. The problem I am having now is that the function "GrantReferralBonus" does not update the users inventory. The referral badge is not being added, so the user can redeem an unlimited amount of times. Am I missing something?

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

·
brendan avatar image
brendan answered

For the first issue, the existing return should work fine, actually. What deserializer are you using? Can you put a breakpoint in and examine the actual value returned and paste that here?

For the second issue, it's hard to say without knowing what all the changes are that you made. What I would recommend us putting some output logs into your script to test what the response is when you add the referral badge to the player, to make sure there aren't any errors in the process. If there are, and you're having trouble debugging the issue, can you post the specifics of the error here as well?

5 comments
10 |1200

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

ebrahimB avatar image ebrahimB commented ·
1) Ok so I added logs in the cloud script and my code. This is the log in my code: 
Debug.Log("result.FunctionResult is null? " + (result.FunctionResult == null));

Which returns true. Here are the logs in the cloud script at the end of the RedeemReferral function:

var grantedItems = GrantReferralBonus(args.referralCode);
log.info("grantedItems " + grantedItems);
return grantedItems;

and that returns

grantedItems [object Object]

so not null.

0 Likes 0 ·
ebrahimB avatar image ebrahimB commented ·

2) So I tried getting the response but I think I am not calling the right function (The cloud script stuff has always been a bit funky editing since there isn't an auto-complete). Here are the logs in grant referral bonus:

log.info("GrantItemsToUserResult " + GrantItemsToUserResult);
log.info("GrantItemsToUserResult response: " + GrantItemsToUserResult.response);

Here are the respective outputs:

GrantItemsToUserResult [object Object]
GrantItemsToUserResult response: undefined

I tried entering the info into the doc samples and here was the response:

{
 "code": 200,
 "status": "OK",
 "data": {
  "ItemGrantResults": [
   {
    "PlayFabId": "53A1C946683F2BEA",
    "Result": false,
    "ItemId": "referralBadge",
    "Annotation": "test",
    "UnitPrice": 0
   }
  ]
 },
 "CallBackTimeMS": 360
}

That makes me think that everything is good, but there are no items in that players inventory.

0 Likes 0 ·
brendan avatar image brendan ebrahimB commented ·

[object Object] is the default string conversion for an object in JavaScript. Can you try using JSON.stringify() on the object, to see what's those objects?

Also, what CatalogVersion are you specifying when you make the call? Bear in mind that if you're not specifying your "ReferralCode" version, you'll be using your primary. Also, it's worth noting that the original design of the service was that all items for the game would be in a single catalog - hence, the reason we use "CatalogVersion" instead of "CatalogId". It's not a requirement, but it does make things easier in some ways (like the fact that receipt validation currently operates on the primary catalog version).

0 Likes 0 ·
ebrahimB avatar image ebrahimB brendan commented ·

Here is the result from granting the items:

GrantItemsToUserResult 

{"ItemGrantResults":[{"PlayFabId":"53A1C946683F2BEA","Result":true,"ItemId":"REFERRAL_PACK_ONE","ItemInstanceId":"8C53140EE3AFB7E0","ItemClass":"Pack","PurchaseDate":"2016-12-02T03:47:06.776Z","Expiration":"2016-12-02T03:47:09.776Z","Annotation":"Referred by: D48BD2176818B8B0","CatalogVersion":"ReferralCode","DisplayName":"Referral Pack 1","UnitPrice":0,"BundleContents":[]},{"PlayFabId":"53A1C946683F2BEA","Result":true,"ItemId":"referralBadge","ItemInstanceId":"65B05B955B05D367","ItemClass":"Badge","PurchaseDate":"2016-12-02T03:47:06.776Z","Annotation":"Referred by: D48BD2176818B8B0","CatalogVersion":"ReferralCode","DisplayName":"Referral Badge","UnitPrice":0}]}

So in the cloud script the object is there but when I call

result.FunctionResult

I'm still getting null.

I wasn't setting the catalog version before, but now that I am, the item is being added to the inventory. Thanks!

The function result is still null though.

0 Likes 0 ·
Show more comments

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.