question

Ozan Yilmaz avatar image
Ozan Yilmaz asked

Can I cancel updates if Cloudscript fails?

Hello everyone,

I was wondering if there's any way to cancel/reverse changes if Cloudscript fails. For example; let's say I grant an item to a user in the cloudscript and then update the user's data. If updating the user data fails, I want to revoke/take back the item I granted to the user, or vice-versa. Is that possible?

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

·
Sarah Zhang avatar image
Sarah Zhang answered

We don’t provide the official feature to revoke the API calls in the failed CloudScript functions. As the workaround, you can call the Server APIs manually to revoke the corresponding updates. For example, you can use the Server API RevokeInventoryItem or RevokeInventoryItems to revoke the inventory items you granted. To revoke the user data updates, you need to call the UpdateUserData, UpdateUserInternalData, UpdateUserReadOnlyData, etc. to update the data to the previous version manually. We would suggest you verify the corresponding data updates before granting users items.

If you meet the more complex situation, for instance, the CloudScript function is blocked since the time out or other Internal Server Errors, the error would be difficult to be identified. For such API errors, you can add the try-catch to function so that you can handle the errors using your own code. Please check this documentation -- Handling Errors in CloudScript - PlayFab | Microsoft Docs for more information. As for the problems caused by CloudScript function's own logic, they cannot be caught by try-catch, it is recommended to solve these problems in the development stage.

10 |1200

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

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.