Script repository

Deny pending approval requests for the operations on the target object

Updated on: Jan 18, 2026, Views: 4709

Approval requests

The script denies pending approval requests for the operations on the target object. To execute the script, create a business rule, custom command or scheduled task configured for the required object type.

In the script, the $denyReason variable specifies the reason for approval requests cancellation.

$denyReason = "The user was deleted" # TODO: modify me

# Bind to the 'Approval Requests' container.
$requestsPath = $Context.GetWellKnownContainerPath("ApprovalRequests")
$container = $Context.BindToObject($requestsPath)

# Get all pending approval requests.
$requests = $container.GetApprovalRequests("ADM_APPROVALSTATE_PENDING")

foreach ($requestID in $requests)
{
    # Bind to the approval request.
    $guid = New-Object "System.Guid" (,$requestID)
    $guid = $guid.ToString("B")
    $requestPath = "Adaxes://<GUID=$guid>"
    $request = $Context.BindToObject($requestPath)

    # Get the target object GUID.
    $targetObjectGuid = New-Object "System.Guid" (,$request.Get("adm-TargetObjectGuid"))
    $targetObjectGuid = $targetObjectGuid.ToString()

    # Skip if request is not for target object.
    if($targetObjectGuid -ine "%objectGUID%")
    {
        continue
    }

    # Deny the request.
    $request.Deny($denyReason)
}

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.