Delegation conditions are fail-closed. If the script returns an empty list, or never calls
actions.delegate, no delegate is eligible and the request stays with its original reviewer.Write a delegation-condition script
Read the request withcontext.get_request(), decide who may cover it, and declare the eligible delegates with actions.delegate(...).
context module
Returns the request being evaluated, withrequester_id, target_user_id, requested_resources, and the other request fields. It is the same object documented for request review.
actions module
Declares the delegates eligible to cover the request. This call is terminal: the script ends when it runs.list[string]
required
The user IDs of the eligible delegates. Pass an empty list to make no delegate eligible.
entity, requests, risk, and time. Use them to look up users, groups, resources, tags, and request history to make the decision. access, notifications, tickets, http, and secrets are not available.
Limits
- A delegation condition script must finish within 5 seconds. A script that times out makes no delegate eligible.
actions.pauseandactions.pollaren’t available. The script must decide in one pass.- Any error, such as an invalid user ID passed to
actions.delegate, also makes no delegate eligible.
Use a delegation-condition script
Create a delegation-condition script, then set it as the condition on a request-reviewer delegation. The delegation forwards a request to a delegate only when the script makes that delegate eligible. When the script makes no delegate eligible, the request stays with its original reviewer.- Navigate to Admin > OpalScript > Editor, select +, and choose Approval delegation as the script type. Start from a template (by team tag, by requester, or by resource) or a blank script.
- When you create a delegation in Inventory > Delegations, select the script under Condition script. You can also create a new condition script from that field.