Set Access Codes for Role landing.role.setAccessCodes

We are still updating this page

Some data may be missing here — we will fill it in shortly.

Scope: landing | Execution Rights: administrator

The method landing.role.setAccessCodes sets access codes for a role, which will apply to this role (and its restrictions on sites). The method takes the role identifier and an array of access codes as input. If the array is empty, the codes for the role will be reset.

Permissions are independent and can be granted selectively. For example, a user may have only the right to publish without the ability to make any changes.

The following values can be used as keys:

  • SG - workgroup, for example SG1 - workgroup with identifier 2;
  • U - user, for example U45 - user with identifier 45;
  • DR - department, including subdivisions, for example DR23 - section with identifier 23;
  • UA - all authorized users.
  • G - user group, for example G2 - user group with identifier 2.

Parameters

Parameter

Description

id
unknown

Role identifier.

codes
unknown

Array of access codes.

Examples

try
        {
        	const response = await $b24.callMethod(
        		'landing.role.setAccessCodes',
        		{
        			id: 11,
        			codes: [
        				'SG3_A', 'G4'
        			]
        		}
        	);
        	
        	const result = response.getData().result;
        	console.info(result);
        }
        catch( error )
        {
        	console.error(error);
        }
        
try {
            $response = $b24Service
                ->core
                ->call(
                    'landing.role.setAccessCodes',
                    [
                        'id'    => 11,
                        'codes' => [
                            'SG3_A', 'G4'
                        ],
                    ]
                );
        
            $result = $response
                ->getResponseData()
                ->getResult();
        
            echo 'Success: ' . print_r($result, true);
            // Your required data processing logic
            processData($result);
        
        } catch (Throwable $e) {
            error_log($e->getMessage());
            echo 'Error setting access codes: ' . $e->getMessage();
        }
        
BX24.callMethod(
            'landing.role.setAccessCodes',
            {
                id: 11,
                codes: [
                    'SG3_A', 'G4'
                ]
            },
            function(result)
            {
                if(result.error())
                {
                    console.error(result.error());
                }
                else
                {
                    console.info(result.data());
                }
            }
        );
        

How to Use Examples in Documentation