question

appgame avatar image
appgame asked

User-Specific { Andriod DeviceID } "Error": "JavascriptException" on "requester" -> "requestee" -> "Confirmed"

Hello, 


Error: JavascriptException
StackTrace:
	TypeError: Cannot read property 'apiError' of undefined
	at handlers.SearchFriendsRequest

ExecuteCloudScript:

    MakeFriendRequest() SUCCESS: 1:02 PM

    • LOOP WAIT FAIL - on SetFriendTags
    • SetFriendTags -> "requester" -> "requestee" -> "Confirmed"

    SearchFriendsRequest() Error: JavascriptException


    Event History:

    handlers.SearchFriendsRequest = function (args, context) {
        try {
            var Friends = new Array();
            var FriendsList = server.GetFriendsList({
                    PlayFabId: args.PlayFabId, 
                    IncludeFacebookFriends: false, 
                    IncludeSteamFriends: false,
                    ProfileConstraints: { ShowTags : true }
            }).Friends;
            if( args.Page == "All" ){
                var Start = 0; 
                var End = FriendsList.length;
            }else{
                var END = ( parseInt(args.Page) * 20 );
                var START = (END - 20);
            };
            for(var i = START; i < END ; i++){
                var F = FriendsList[i];
                if(F == undefined){ break; };
                if(F.Tags.indexOf(args.Tag) > -1 || args.Tag == "EDIT" ){ Friends.push(F); };
            };
        } catch (ex) {
                let error = ex.apiErrorInfo.apiError.error;
                let errorCode = ex.apiErrorInfo.apiError.errorCode;
        };
        return { FriendsList : Friends };
    }
    error4.png (41.6 KiB)
    4 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.

    appgame avatar image appgame commented ·

    Platform-DeviceID-Specific Error

    0 Likes 0 ·
    error3.png (372.6 KiB)
    appgame avatar image appgame commented ·

    Deleted Comment

    0 Likes 0 ·
    appgame avatar image appgame commented ·

    Your refreshment is ready :)

    0 Likes 0 ·
    starbucks.jpg (119.2 KiB)
    appgame avatar image appgame commented ·
    import java.net.HttpURLConnection;
    import java.net.URL;
    
    JAVA:
    private static Object doPostPrivate(String url, String bodyString, String authType, String authKey) throws Exception {}
    
    
    HttpURLConnection con = (HttpURLConnection) new URL(url).openConnection();
    con.setRequestMethod("POST");
    
    
    
    ExecuteCloudScript: Response,
     1, SearchFriendsRequest() Error:	JavascriptException
    
    
    
    
    0 Likes 0 ·
    error5.png (56.7 KiB)
    appgame avatar image
    appgame answered

    Hello,

    Requester Tags : "requester" was not set -> SetFriendTags()
    
    MakeFriendRequest()
    /* Add Friend to your FriendsList */
    1, AddFriend()		->	"Success: OK "
    2, SetFriendTags()	->	"requester"	->	"Success: FAIL"
    
    
    /* Add to your Friends FriendsList */
    3, AddFriend()		->	"Success: OK "
    4, SetFriendTags()	->	"requestee"	->	"Success: OK "

    LOOP WAIT FAIL: on MakeFriendRequest() -> SetFriendTags()
    
    
    
    Possible ExecuteCloudScriptRequest "LOOP WAIT" Failure.
    
    	1, MakeFriendRequest() ->	Tags : "requester" or "requestee"
    	2, FriendsRequestConfirmed() ->	Tags : "Confirmed"
    	3, FriendsRequestDeclined() ->	RemoveFriend()
    
    
    FriendsList[i].Tags.indexOf() caused this Error.
    
    for( var i = START; i < END; i++){
    	var FAIL = 0;
    	var Found = 0;
    
    	var F = FriendsList[i];
    
    	if( F == undefined ){ break; }
    
    	/* Possible LOOP WAIT: Single Fail */
    	        if( F.Tags == undefined  ){ F["Tags"] = []; }
    	        if( F.Tags.length == 0 ){
    
    
    		FAIL = 1;
    		var FF = server.GetFriendsList({
    			PlayFabId: F.FriendPlayFabId,
    			IncludeFacebookFriends: false,
    			IncludeSteamFriends: false,
    			ProfileConstraints: { ShowTags : true }
    		}).Friends;
    
    		for(var z = 0; z < FF.length ; z++){
    			if(FF[z].FriendPlayFabId==args.PlayFabId){Found=FF[z];}
    		}
    
    		if( Found != 0 ){
    			/* Possible LOOP WAIT: Double Fail */
    			        if( Found.Tags==undefined ){Found["Tags"] = [];}
    			        if( Found.Tags.length == 0){
    
    				FAIL = 2; 
    			}else{
    				FAIL = 0;
    				/* Reset Friend Request */
    				TAG = Found.Tags[0];
    				T=(TAG=="requestee") ? "requester": "requestee";
    				Tag=(TAG=="Confirmed") ? "Confirmed": T;
    				var apiResult = server.SetFriendTags({
    					"PlayFabId": args.PlayFabId,
    					"FriendPlayFabId": F.FriendPlayFabId,
    					"Tags": Tag
    				});
    			}
    		}
    	}
    
    
    	if( FAIL == 0 ){
    		if ( F.Tags.indexOf(args.Tag ) > -1 || args.Tag == "EDIT" ){
    			Friends.push(F);
    		};
    	}
    
    	if( FAIL > 0 ){
    		/* Remove Friend from your FriendsList */
    		var apiResult = server.RemoveFriend({
    			"PlayFabId": args.PlayFabId,
    			"FriendPlayFabId": F.FriendPlayFabId,
    		});
    	}
    
    	if( FAIL > 1 ){
    		/* Remove Yourself From Friends->FriendsList */
    		var apiResult = server.RemoveFriend({
    			"PlayFabId": Found.FriendPlayFabId,
    			"FriendPlayFabId": args.PlayFabId,
    		});
    	}
    }
    <br>

    error6.png (36.2 KiB)
    10 |1200

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

    appgame avatar image
    appgame answered

    Hello,

    1. Be a GOOF & Search "None" as Display Name.
    2. AddFriend() creates Phantom friend with no SetFriendTags.
    3. Solve serious problems you just created.
    4. Have a Ha, Ha, Ha, Ha Weekend..
    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.