dx-org-permission-set-assign

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

dx-org-permission-set-assign

dx-org-permission-set-assign

Assigns one or more permission sets to org users using
sf org assign permset
. Handles all variants: default admin user, specific org targets, multiple permission sets, and assignment to specific users.

使用
sf org assign permset
为组织用户分配一个或多个权限集。支持所有场景:默认管理员用户、特定组织目标、多个权限集以及为特定用户分配权限集。

⚠️ Tool Restrictions

⚠️ 工具限制

Use ONLY the Bash tool to execute
sf org assign permset
. Do NOT use MCP tools like
assign_permission_set
— ignore them completely.

仅使用Bash工具执行
sf org assign permset
。请勿使用
assign_permission_set
等MCP工具——完全忽略它们。

Scope

适用范围

  • In scope: Assigning permission sets to users via
    sf org assign permset
  • Out of scope: Creating permission sets (use
    platform-permission-set-generate
    ), listing permission sets, checking user permissions

  • 包含场景:通过
    sf org assign permset
    为用户分配权限集
  • 排除场景:创建权限集(使用
    platform-permission-set-generate
    )、列出权限集、检查用户权限

Required Inputs

必填输入项

Infer from the user's request:
  • Permission set name(s): Extract from user message (can be multiple)
  • Target org: Use default unless specific alias/username mentioned
  • Target user(s): Default is org's default admin user; use
    --on-behalf-of
    if specific users mentioned

从用户请求中推断:
  • 权限集名称:从用户消息中提取(可多个)
  • 目标组织:除非提及特定别名/用户名,否则使用默认组织
  • 目标用户:默认是组织的默认管理员用户;若提及特定用户,使用
    --on-behalf-of
    参数

Workflow

工作流程

  1. Match user request to command in table below
  2. Execute via Bash tool:
    sf org assign permset
    with appropriate flags and
    --json
    flag
  3. Return result
If error occurs, check the
failures
array in JSON output for details.
  1. 将用户请求与下表中的命令匹配
  2. 通过Bash工具执行:带适当标志和
    --json
    标志的
    sf org assign permset
  3. 返回结果
若发生错误,检查JSON输出中的
failures
数组获取详细信息。

Command Decision Table

命令决策表

User intentExecute via Bash tool
Assign one permission set to default admin
sf org assign permset --name <PermSetName> --json
Assign multiple permission sets to default admin
sf org assign permset --name <PermSet1> --name <PermSet2> --json
Assign to specific org
sf org assign permset --name <PermSetName> --target-org <alias> --json
Assign to specific user(s)
sf org assign permset --name <PermSetName> --on-behalf-of <username1> --on-behalf-of <username2> --json
Assign multiple sets to specific users
sf org assign permset --name <PermSet1> --name <PermSet2> --on-behalf-of <username1> --on-behalf-of <username2> --json

用户意图通过Bash工具执行的命令
为默认管理员分配单个权限集
sf org assign permset --name <PermSetName> --json
为默认管理员分配多个权限集
sf org assign permset --name <PermSet1> --name <PermSet2> --json
为特定组织分配权限集
sf org assign permset --name <PermSetName> --target-org <alias> --json
为特定用户分配权限集
sf org assign permset --name <PermSetName> --on-behalf-of <username1> --on-behalf-of <username2> --json
为特定用户分配多个权限集
sf org assign permset --name <PermSet1> --name <PermSet2> --on-behalf-of <username1> --on-behalf-of <username2> --json

Rules / Constraints

规则与约束

ConstraintRationale
Always use
--json
flag
Provides structured output for reliable parsing and error handling
Permission set names are case-sensitiveUse exact API names as they appear in the org
Multiple
--name
flags can be combined in one command
More efficient than separate commands per permission set
Multiple
--on-behalf-of
flags assign to multiple users
Batch assignment in single command; processed sequentially to avoid auth file collisions
Use CLI username aliases, not Salesforce User.Alias fieldThe
--target-org
and
--on-behalf-of
flags expect CLI aliases set via
sf alias set
, not the User object's Alias field
Duplicate assignments are idempotentRe-assigning an already-assigned permission set succeeds silently
Partial success is possibleCommand can return both successes and failures in one run; non-zero exit code if any failures

约束条件理由
始终使用
--json
标志
提供结构化输出,便于可靠解析和错误处理
权限集名称区分大小写使用组织中显示的准确API名称
可在单个命令中组合多个
--name
标志
比为每个权限集单独执行命令更高效
多个
--on-behalf-of
标志可分配给多个用户
单命令批量分配;按顺序处理以避免认证文件冲突
使用CLI用户名别名,而非Salesforce User.Alias字段
--target-org
--on-behalf-of
标志需要通过
sf alias set
设置的CLI别名,而非User对象的Alias字段
重复分配具有幂等性重新分配已分配的权限集会静默执行成功
可能出现部分成功命令可在一次运行中同时返回成功和失败结果;若存在任何失败,退出码为非零

Gotchas

常见问题与解决方法

IssueResolution
Permission set name with spacesEnclose in double quotes:
--name "Permission Set Name"
"PermissionSet not found" errorVerify permission set exists in target org; check for typos in name
Assignment succeeds but user doesn't see permissionsCheck
<hasActivationRequired>
in permission set metadata — may need manual activation in Setup
"User not found" errorUsername/alias doesn't exist in target org — verify with
sf org display user --target-org <alias>
Partial success (some users succeed, others fail)Check JSON output — command returns both
successes
and
failures
arrays; exit code will be non-zero if any failures occurred

问题解决方法
权限集名称包含空格用双引号包裹:
--name "Permission Set Name"
"PermissionSet not found"错误验证权限集是否存在于目标组织;检查名称拼写错误
分配成功但用户看不到权限检查权限集元数据中的
<hasActivationRequired>
字段——可能需要在Setup中手动激活
"User not found"错误用户名/别名在目标组织中不存在——使用
sf org display user --target-org <alias>
验证
部分成功(部分用户成功,部分失败)检查JSON输出——命令会返回
successes
failures
两个数组;若存在任何失败,退出码为非零

Output Expectations

输出预期

The command returns JSON output with status code and result details.
See
examples/success_output.json
and
examples/error_output.json
for response structures.

命令返回包含状态码和结果详情的JSON输出。
查看
examples/success_output.json
examples/error_output.json
了解响应结构。

Reference File Index

参考文件索引

FileWhen to read
examples/success_output.json
To understand successful assignment response structure
examples/error_output.json
To handle common error scenarios
references/cli_flags.md
For detailed explanation of all available flags
文件阅读场景
examples/success_output.json
了解成功分配的响应结构
examples/error_output.json
处理常见错误场景
references/cli_flags.md
获取所有可用标志的详细说明