question

stevfofetta avatar image
stevfofetta asked

create a group with the user who created it as admin cloudscript

hello i would like to create a group and put the user who created it as admin i use entity.createGroup(groupName) but it puts the id of my project as admin of the group

sdks
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

·
Xiao Zha avatar image
Xiao Zha answered

You may try specifying the Entity parameter of the CreateGroup API. And please remember to use ExecuteEntityCloudScript API (https://learn.microsoft.com/en-us/rest/api/playfab/cloudscript/server-side-cloud-script/execute-entity-cloud-script?view=playfab-rest) to execute the Cloud Script function so that function will be provided with entity profile. Below is my working Cloud Script code.

 handlers.CreateGroup=function(args,context)
 {
     var entityProfile = context.currentEntity;
     var result= entity.CreateGroup({
                
             Entity:entityProfile.Entity,
             GroupName: args.groupname
    
         });
 }

In addition, if you are using ExecuteCloudScript instead of ExecuteEntityCloudScript, you could refer to https://community.playfab.com/questions/42193/cloudscriptexecuteentitycloudscript-vs-clientexecu.html to have more information about the difference between these two APIs.

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.