Script repository

Add user from DN syntax property to approvers

Updated on: Jan 18, 2026, Views: 4515

Approval requests

The script adds a user from a DN syntax property to the approvers list of all pending approval requests awaiting actions from the target user. To execute the script, create a business rule, custom command or scheduled task configured for the User object type.

In the script, the $newApproverDNProperty variable specifies the name of the property storing the approver to add.

$newApproverDNProperty = "assistant" # TODO: modify me

# Get new approver DN.
try
{
    $newApproverDN = $Context.TargetObject.Get($newApproverDNProperty)
}
catch
{
    $Context.LogMessage("Property '$newApproverDNProperty' is empty", "Warning") # TODO: modify me
    return
}

# Get all requests awaiting approval by user.
$requests = $Context.TargetObject.GetApprovals("ADM_APPROVALSTATE_PENDING")
if ($requests.Length -eq 0)
{
    return
}

# Bind to the new approver.
$newApprover = $Context.BindToObjectByDN($newApproverDN)

foreach ($requestID in $requests)
{
    # Bind to the request.
    $requestGuid = [Guid]$requestID
    $path = "Adaxes://<GUID=$requestGuid>"
    $request = $Context.BindToObject($path)
    
    # Get approvers info.
    $approversInfo = $request.GetApproversInfo()
    
    # Check whether the new approver is already on the list.
    if ($approversInfo.IsApproverEx($newApprover, $request.Requestor, $request.TargetObject))
    {
        continue
    }

    # Add approver
    $approverTrustees = $approversInfo.ApproverTrustees
    $approverTrustees.Add($newApprover)
    
    # Update the approvers list.
    $request.SetApproversInfo($approversInfo)
    $request.SetInfo()
}

Comments 0

You must be signed in to comment.

    Got questions?

    Support Questions & Answers

    We use cookies to improve your experience.
    By your continued use of this site you accept such use.
    For more details please see our privacy policy and cookies policy.