question

Michal Töpfer avatar image
Michal Töpfer asked

Execute Cloud Script With Arguments

One of the actions in PlayStream is Execute CloudScript. Is it possible to pass some arguments to the function (FunctionParameter in requests from client)?

CloudScriptPlayStream
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

Yes, there are two mechanisms to get arguments into your Cloud Script, based upon how it is launched. For regular, client calls to ExecuteCloudScript, you can of course just use FunctionParameter, and those parameters will show up in the args. There are examples showing how to do this in our Samples repo in GitHub, here: https://github.com/PlayFab/PlayFab-Samples

For PlayStream, the event itself is passed into the Cloud Script, so that you can use any parameters from it for your logic. In your Cloud Script handler, make sure to use both the args and context inputs like so:

handlers.onSomeAction = function (args, context)

When a handler is triggered via PlayStream, the inputs will all be in the Context. This includes a playerProfile object, which contains all the info on the player that triggered the call (the PlayFabId, Statistics, LinkedAccounts, etc.), but in addition, it also contains a playStreamEvent object, which is specifically the event that triggered the handler to run.

2 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.

Michal Töpfer avatar image Michal Töpfer commented ·

I think I didn't stress enough that I was writing about PlayStream Action.

0 Likes 0 ·
brendan avatar image brendan Michal Töpfer commented ·

No, completely my fault - I've updated the answer to have the full breakdown, so that your question is answered, as well.

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.