User roles
Update user-role mapped fields
/a/UserRole_updateData
Update one or more user roles through CRM2’s generic field map.
When to use this endpoint
Use UserRole_updateData for role-name edits from CRM2’s role list/detail screens. Access fields are updated separately.
Authentication and permissions
The authenticated context must contain pageUserRoles_edit or the global all role permission.
The permission check runs before explicit login validation. Its legacy denial text incorrectly says “copy role.”
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Integer string or native array | Yes | Target role ID or native list. Bulk mode runs sequentially, discards per-row results, and returns success. JSON array text is not decoded. |
name | String | No | Complete replacement. Blank and duplicate names are accepted on update; there is no endpoint length check before the 100-character column. |
cDate | Datetime string | No | Replacement creation datetime. Blank becomes SQL null; nonblank input is not date-validated. |
lastEdited | Unix seconds or date text | No | Mapped input is accepted, but any actual change appends the current Unix time and therefore overrides an explicit value. |
noRecord | Native array | No | Internal audit control listing mapped keys whose history should be hidden. |
Example request
$result = FM_api('UserRole_updateData', [
'id' => '12',
'name' => 'Senior dispatch supervisor',
]);
Example response
{
"ok": 1
}
Scalar no-op input returns {"warning":"No Change."}; a missing row returns {"warning":"No data."}; unknown-only update keys return {"warning":"no updated fields."}.
Errors and unusual responses
| Response | Condition |
|---|---|
{"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 copy role."} | The edit permission is absent; this is the handler’s misleading legacy text. |
{"error":"missing or invalid parameter: id"} | The ID key is absent. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Unknown keys are ignored. Scalar zero normally returns
No data.; there is no explicit positive-ID validation. - Any mapped change advances
last_editedto current Unix seconds. - Role access and assigned users are not changed.
Side effects
- Updates matching role rows, invalidates the user-roles cache, and writes generic field-level audit history.
- Bulk mode is non-transactional and hides individual warnings/errors.
See it in Fieldmotion
CRM1
No direct CRM1 caller was found.
CRM2
Editing a role from Users → Roles or its detail screen calls this route after a client-side duplicate-name check.
Related endpoints
UserRole_updateFieldis the administrator-only field-level writer.UserRoleAccess_updateAccesssaves the access configuration separately.