Search code examples
salesforcesandboxtooling

How to give access to a group of users after refreshing a salesforce sandbox?


I would like a group of users to have access to a sandbox after it has been refreshed without manually activating them.

From my understanding this should be possible after the spring '23 release with the introduction of the field ActivationUserGroupId on the SandboxInfo object.

When I try to refresh the sandbox using the tooling API I get this error

[
    { 
        "message": "No such column 'ActivationUserGroupId' on sobject of type SandboxInfo",
        "errorCode": "INVALID_FIELD"
    }
]

I'm requesting for a refresh using {{_endpoint}}/services/data/v57.0/tooling/sobjects/SandboxInfo/{{sandbox_id}} where {{_endpoint}} is the production org's endpoint and {{sandbox_id}} is the id of the sandbox to refresh. The payload of the request is as follows

{
    "LicenseType": "DEVELOPER_PRO",
    "AutoActivate": true,
    "ActivationUserGroupId": "{{group_id}}"
}

where the {{group_id}} is the id of the group in production which should get access to the sandbox after refresh.

If I remove the ActivationUserGroupId attribute in the body the request works. However, then the group of users does not get access.

PS: The production org is running release spring '23. However, when using the tooling API v57.0 to describe the SandboxInfo object there is no field named ActivationUserGroupId.


Solution

  • I just tested the ActivationUserGroupId using SandboxInfo and confirmed this is now working. My requests are made with API v57.0.

        sandbox_data = {
            'LicenseType': 'DEVELOPER',
            'SandboxName': sandbox_name,
            'ActivationUserGroupId': 'group_ID'
        }