When to use this endpoint

Use UserRoleAccess_updateAccess to save the CRM2 role Access page or initialize access on a new role.

Authentication and permissions

The authenticated context must contain pageUserRole_edit or the global all role permission.

The permission check runs before explicit login validation.

Parameters

ParameterTypeRequiredDescription
idInteger stringYesTarget role ID after integer conversion; it must be greater than zero. Role existence is not checked.
accessNative arrayYesComplete list of access-field strings. Values are not checked against the catalogue or SQL-escaped.

Example request

$result = FM_api('UserRoleAccess_updateAccess', [
	'id' => '12',
	'access' => ['pageUserRoles_view', 'pageApp_quick_complete'],
]);

Example response

{
  "ok": 1
}

Errors and unusual responses

ResponseCondition
{"error":"not logged in"}No authenticated tenant context is available. Invalid signed credentials can be rejected by the dispatcher before the handler runs.
{"error":"You do not have the correct permissions to edit roles."}The role-overview edit permission is absent.
{"error":"missing or invalid parameter: id"}The key is absent or integer-converts below 1.
{"error":"missing or invalid parameter: access"}The key is absent.
Runtime warning/type erroraccess is not the expected native array.

Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.

Behaviour and edge cases

  • Inserted access rows omit last_edited and normally retain the schema default 0. Duplicate/unknown fields are stored and nonexistent role IDs can receive orphan rows.
  • The assigned-user app_permissions bitmask is rebuilt from exact fields: pageApp_customers_section=1, pageApp_no_new_appointments=2, pageApp_quick_complete=4, pageApp_load_all_customers=8, pageApp_dropbox=16, pageApp_archives=32, pageApp_job_rejection=64, pageApp_job_change_user=128, pageApp_job_edit_customer=256, pageApp_assets_section=512, pageApp_load_all_assets=1024, pageApp_job_copy=2048, pageApp_lock_date_range=4096, pageApp_create_assets=8192, pageApp_disable_customer_job_history=16384, pageApp_stocks_section=32768, pageApp_asset_value=65536, pageApp_job_page_stock=131072, pageApp_job_page_sor=262144, pageApp_view_jobs_calendar=524288, pageApp_view_leave_requests=1048576, and pageApp_job_edit_jobtime=2097152.
  • All other access fields affect stored CRM permissions only and contribute no bit. The handler does not filter fields by tenant feature settings.

Side effects

  • Replaces all user_role_accesses rows for the ID and invalidates that cache.
  • Updates app_permissions for every tenant user whose role_id matches and invalidates the users cache. It does not advance user/role timestamps or write audit history.

See it in Fieldmotion

CRM1

No direct CRM1 caller was found.

CRM2

Creating a role enables the default quick-complete field through this route. Saving a role’s Access page sends the full calculated list, including four UI-inverted choices.

Related endpoints