Microsoft Azure PlayFab logo
    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Add-ons
    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA
  • Runs on PlayFab
  • Pricing
    • Blog
    • Forums
    • Contact us
  • Sign up
  • Sign in
  • Ask a question
  • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges
  • Home /
  • API and SDK Questions /
avatar image
Question by Muhammad Roshaan Tariq · Mar 06, 2020 at 12:16 PM · CloudScriptapissdks

How can I Remove member from Group/Clan using Cloudscript?

Hi,

I want to use cloudscript for removing members from group using this API. I have written a function using the best of my knowledge of Playfab's Cloudscripting

here's my cloud code:

handlers.leaveGroup = function(args,context){
  var removeGroupMember = {
      "Group":{
          "Id": args.groupID
      },
      "Members":{
          "Entity":{
              "Id": args.userID,
              "Type": "title_player_account",
              "TypeString": "title_player_account"
          }
      }
  };
  
  var response = entity.RemoveMembers(removeGroupMember);
  return response;
};

When I send the request from my game I get the response as NULL and I don't understand why it is happening.

here's my code from my game:

internal void LeaveGroup(string _groupID)
{
    requestCompleted = false;

    PlayFabAuthenticationAPI.GetEntityToken(new PlayFab.AuthenticationModels.GetEntityTokenRequest(), result =>
    {
        ExecuteCloudScriptRequest cloudCodeRequest = new ExecuteCloudScriptRequest
        {
            FunctionName = "leaveGroup",
            FunctionParameter = new
            {
                groupID = _groupID,
                userID = result.Entity.Id
            }
        };

        PlayFabClientAPI.ExecuteCloudScript(cloudCodeRequest, OnSuccessfulResponse, OnFailedResponse);
    }, OnFailedResponse);
}

private void OnSuccessfulResponse(ExecuteCloudScriptResult result)
{
    Debug.Log("Success");
    Debug.Log(result.FunctionResult);
}

private void OnFailedResponse(PlayFabError error)
{
    Debug.LogError("Error Report: " + error.GenerateErrorReport());
}
Comment
Roshaan

People who like this

1 Show 0
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Sarah Zhang · Mar 09, 2020 at 03:08 AM

According to this API reference Remove Members, there is not a field whose name is “Entity” in the request body of this API and the value of field “Members” should be an array. Your CloudScript code should be the following one.

handlers.leaveGroup = function (args, context) {
    var removeGroupMember = {
        "Group": {
            "Id": args.groupID
        },
        //Remove "Entity{}", add "[]"
        "Members": [{
            
                "Id": args.userID,
                "Type": "title_player_account",
                "TypeString": "title_player_account"
            
        }]
    };

    var response = entity.RemoveMembers(removeGroupMember);
    return response;
};

Comment

People who like this

0 Show 2 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Muhammad Roshaan Tariq · Mar 09, 2020 at 11:09 AM 0
Share

@Sarah Zhang

And how will I be sending an Array from my C# code in ExecuteCloudScript function?

avatar image Sarah Zhang Muhammad Roshaan Tariq · Mar 13, 2020 at 09:05 AM 0
Share

You can refer to the following code. Please refer to the C# documentation for more information about C# programming language.

  var executeCloudScriptRequest = new ExecuteCloudScriptRequest
        {
            FunctionName = "[YourFunctionName]",
            FunctionParameter = new { members = new string[] { "[YourPlayFabId01]", "[YourPlayFabId02]" }, }
        };

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Navigation

Spaces
  • General Discussion
  • API and SDK Questions
  • Feature Requests
  • PlayStream
  • Bugs
  • Add-on Marketplace
  • LiveOps
  • Follow this Question

    Answers Answers and Comments

    4 People are following this question.

    avatar image avatar image avatar image avatar image

    Related Questions

    Advantages of CloudScript over Calling JavaScript from Node.js 1 Answer

    No confirmation email is received. 5 Answers

    There is a problem with the certificate when using the container. 1 Answer

    Azure Functions - context return null, Scheduled Tasks faild [two questions] 3 Answers

    No CloudScript functions can be found,No CloudScript functions found 1 Answer

    PlayFab

    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Runs on PlayFab
    • Pricing

    Solutions

    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA

    Engineers

    • Documentation
    • Quickstarts
    • API Reference
    • SDKs
    • Usage Limits

    Resources

    • Forums
    • Contact us
    • Blog
    • Service Health
    • Terms of Service
    • Attribution

    Follow us

    • Facebook
    • Twitter
    • LinkedIn
    • YouTube
    • Sitemap
    • Contact Microsoft
    • Privacy & cookies
    • Terms of use
    • Trademarks
    • Safety & eco
    • About our ads
    • © Microsoft 2020
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Create an article
    • Post an idea
    • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Explore
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges