Loading...
Loading...
Bulk-realign an existing Salesforce UserRole hierarchy from an external org-chart artifact (PDF, xlsx, or plain-text list of role-and-parent pairs) in one admin-approved manifest. Clarify scope and whether users move with roles, resolve identities that do not match verbatim, diff the artifact against the current tree, and submit create, rename, reparent, empty-role delete, and user-assignment mutations together. Triggers on "reorganize the role hierarchy", "apply this org chart to roles", "bulk update role parents", "realign roles from PDF", "restructure the role hierarchy", "reparent roles from this spreadsheet". Do not trigger for a single role create, rename, or reparent with no other changes, or for asking which roles exist or how they are nested — that is `managing-roles`. Do not trigger for territory, account, or forecast hierarchies, or for authoring sharing rules.
npx skill4agent add forcedotcom/sf-skills platform-role-hierarchy-applymanaging-roles.xlsx.csvrole_nameparent_role_nameRole: Parent{roleName, parentRoleName}NameDeveloperNameAssignUserMoveUserSELECT Id, DeveloperName, Name, ParentRoleId
FROM UserRole
LIMIT 10000DeveloperNameName{roleName, parentRoleName, users?}Role: ParentDeveloperNameNameDeveloperNameId005User.IdUser.EmailUser.UsernameUser.NameIsActive = falseA → B → C → AoperationIdoperationTypedependsOnOperationIdsdependsOnOperationIds| operationType | Nested object | Use when |
|---|---|---|
| | Role is in the artifact and not in the org. Set |
| | Role exists and the parent differs. Set |
| | Same role, different label or developer name. Set the expected and desired name fields. |
| | Admin asked to remove an empty role. Set |
| | Reassignment was confirmed. Set |
DeleteRoleoperationIddependsOnOperationIdsmissing-parentCreateRoledependsOnOperationIdsroleReferencedeveloperNameAssignUserMoveUserDeleteRoledeveloperNameTerritory2.UserRoleIdPortalType != 'None'SELECT COUNT() FROM User WHERE UserRoleId = :idRestructure preview
-------------------
ReparentRole : 42
CreateRole : 3
RenameRole : 1
DeleteRole : 2
MoveUser : 2
Territory / forecast references : 1
Portal roles : 0
Roles with more than 500 users : 2
Approve this restructure? [yes / no]yesPOST /services/data/v{version}/sharing/role-hierarchy-restructure
{
"operation": "Save",
"mutations": [
{
"operationId": "reparent-sales-vp",
"operationType": "ReparentRole",
"dependsOnOperationIds": [],
"reparentRole": {
"targetRoleId": "00E000000000001",
"expectedParentRoleId": "00E000000000002",
"desiredParentRoleReference": "cro"
}
},
{
"operationId": "delete-legacy-region",
"operationType": "DeleteRole",
"dependsOnOperationIds": ["reparent-legacy-children"],
"deleteRole": {
"targetRoleId": "00E000000000003",
"expectedParentRoleId": "00E000000000002",
"expectedAssignedUserIds": [],
"expectedDirectChildRoleIds": []
}
}
]
}CreateRoleRenameRoleAssignUserMoveUserUserRoleAppliedAppliedSharingPendingAsyncExecutionRequiredRoleOperationInProgressNotAppliedreasonCodes404/sobjects/UserRoleoperationResults[]outcomeAppliedNotAppliedDependencyNotAppliedreasonCodeAppliedmanaging-roles| Operation | Purpose | Status | Call | Depends on |
|---|---|---|---|---|
| read | — | | — |
| read | — | | |
| write | — | | |
| verify | — | | |