I get an error message when I want to find out if the players contact email address is confirmed.
What is wrong with my code?
var playerData = server.GetPlayerProfile( { "PlayFabId": currentPlayerId, "ProfileConstraints": {"ShowContactEmailAddresses":true } }) if (playerData.Error == null) { var contactEmailAdresses = playerData.PlayerProfile.ContactEmailAddresses; var playeremail = ""; var emailVerificationStatus = null; if ((contactEmailAdresses != null) && (contactEmailAdresses.length > 0)) { emailVerificationStatus = contactEmailAdresses[0].VerificationStatus; if (emailVerificationStatus != null) { if (emailVerificationStatus == PlayFab.ClientModels.EmailVerificationStatus.Confirmed) playeremail = contactEmailAdresses[0].EmailAddress; else checkemail = "Current contact email is not verified."; } else checkemail = "Current email is not verified."; } else checkemail = "No valid email found."; } else checkemail = "Error";
Error:
"Error": { "Error": "JavascriptException", "Message": "JavascriptException", "StackTrace": "ReferenceError: PlayFab is not defined\n at handlers.CheckContactEmail (E5E2C-main.js:5128:45)\n at Object.invokeFunction (Script:116:33)" }
Answer by Junjin Chen · Oct 30, 2020 at 06:04 AM
I noticed that in line 19 of your code snippet 1, there is “PlayFab.ClientModels.EmailVerificationStatus.Confirmed”. In CloudScript, the “PlayFab” is not defined as the Error explains. To determine whether the status is confirmed, you could write:
if (emailVerificationStatus == “Confirmed”)
The available Status values can be found in: https://docs.microsoft.com/en-gb/rest/api/playfab/server/account-management/getplayerprofile?view=playfab-rest#emailverificationstatus