question

stevfofetta avatar image
stevfofetta asked

create a role in cloudscript

is it possible to create a role in cloudscript?

CloudScript
1 comment
10 |1200

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

stevfofetta avatar image stevfofetta commented ·

here's an example of what I've done, I create the group and I want to use the group id to create a role but it returns a null.

handlers.CreateGroup = function(args){ var groupName = args.groupName;

  try{

//creer le groupe var groupData = entity.CreateGroup({ Entity: args.player, GroupName: groupName }); var groupId = groupData.Group.Id; // Utilisez les API PlayFab pour créer le rôle dans le groupe

 // Appelez l'API PlayFab pour créer le rôle dans le groupe

var role = entity.CreateRole() ({ RoleName: "roleName", RoleId : "roleNam", Group: { Id : groupId, Type : "group" } });

0 Likes 0 ·

1 Answer

·
Xiao Zha avatar image
Xiao Zha answered

If you are referring to the role of the group, you could call the CreateRole API (https://learn.microsoft.com/en-us/rest/api/playfab/groups/groups/create-role?view=playfab-rest) like this: entity.CreateRole() in Cloud Script to create the role for the group.

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

stevfofetta avatar image stevfofetta commented ·

here's an example of what I've done, I create the group and I want to use the group id to create a role but it returns a null

0 Likes 0 ·
stevfofetta avatar image stevfofetta stevfofetta commented ·

///create groupe

handlers.CreateGroup = function(args){

  var groupName = args.groupName;
   try{
 //creer le groupe
 var groupData = entity.CreateGroup({
      Entity: args.player,
      GroupName: groupName
  });
 var groupId =  groupData.Group.Id;
 // Utilisez les API PlayFab pour créer le rôle dans le groupe
  // Appelez l'API PlayFab pour créer le rôle dans le groupe

var role = entity.CreateRole() ({

      RoleName: "roleName",
      RoleId : "roleNam",
      Group:  {
          Id : groupId,
          Type : "group"
      }
      });

return role;

0 Likes 0 ·
Xiao Zha avatar image Xiao Zha stevfofetta commented ·

Sorry for the confusion, you may remove the extra "()" between the "entity.CreateRole" method and the method body.

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.