> ## Documentation Index
> Fetch the complete documentation index at: https://docs.erna.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# preferRole

```ts theme={null}
function preferRole(roleId, opts?): RuleEntry<"role-preference", object & EntityOnlyRuleOptions>;
```

Softly steers multi-role members toward shift patterns tagged with a specific role.

## Parameters

<ResponseField name="roleId" type="string" required>
  The role to prefer
</ResponseField>

<ResponseField name="opts">
  [`EntityOnlyRuleOptions`](./EntityOnlyRuleOptions)

  See [EntityOnlyRuleOptions](./EntityOnlyRuleOptions)
</ResponseField>

## Returns

`RuleEntry`\<`"role-preference"`, `object` & [`EntityOnlyRuleOptions`](./EntityOnlyRuleOptions)>

Penalizes assignment to shift patterns whose `roleIds` do not include
the preferred role. Use `priority` to control preference strength. The member
is still assigned to other roles when coverage or hard constraints require it.
Shift patterns without any `roleIds` (open to all) are also
penalized since they are not explicitly tagged with the preferred role.

The targeted members must actually hold the preferred role in their
`roleIds`. If none of them do, compilation reports an error because
the rule would silently penalize all their assignments (the opposite
of the intent).
