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.

Script Repository

Notify users on pending approval requests initiated by them

November 20, 2023 Views: 2319

This script can be used in business rules, custom commands or scheduled tasks to notify users on pending approval requests they initiated. For example, you can create a custom command that will notify a user on which it is executed.

Note: Pending approval requests are requests that have been neither approved, nor denied, nor canceled.
To add the script to a custom command or scheduled task, use the Run a program or PowerShell script action.


  • $to - Specifies email address of the recipient of the notification.
  • $subject - Specifies the email message subject.
  • $reportHeader - Specifies the email message header.
  • $reportFooter - Specifies the email message footer.
You can use value references (e.g. %mail%) to specify the recipient. When the script is executed, the value references will be replaced with property values of the user on whom it is executed.
Edit Remove
$to = "%mail%" # TODO: modify me
$subject = "Unapproved tasks that you initiated" # TODO: modify me
$reportHeader = @"
<b>List of unapproved tasks that you initiated</b><br/><br/>
<table border="1">
"@ # TODO: modify me
$reportFooter = "<hr /><p><i>Please do not reply to this e-mail, it has been sent to you for notification purposes only.</i></p>" # TODO: modify me

if ([System.String]::IsNullOrEmpty($to))
    # The user doesn't have an email address, exit

# Get all requests initiated by the user
$requests = $Context.TargetObject.GetRequestsForApproval("ADM_APPROVALSTATE_PENDING")
if ($requests.Length -eq 0)
    return # No pending requests

# Get the Web Interface address registered in Adaxes service
$webInterfaceAddress = "%adm-WebInterfaceUrl%"
if ([System.String]::IsNullOrEmpty($webInterfaceAddress))
    $Context.LogMessage("Default web interface address not set for Adaxes service. For details, see http://www.adaxes.com/help/?HowDoI.ManageService.RegisterWebInterface.html", "Warning")

foreach ($requestGuidBytes in $requests)
    # Bind to the Approval Request
    $requestGuid = [Guid]$requestGuidBytes
    $request = $Context.BindToObject("Adaxes://<Guid=$requestGuid>")
    # Get request info
    $approversInfo = $request.GetApproversInfo()
    $approvers = $approversInfo.GetApproversEx($request.Requestor, $request.TargetObject)
    $requestOperation = $request.DescriptionOfOperationToApprove
    # Add request to e-mail notification
    $reportHeader += "<tr><td><a href='$webInterfaceAddress`#/Browse/$requestGuid'>$requestOperation</a></td><td>"

    # Add information on approvers
    foreach ($approver in $approvers)
        $approverGuid = (New-Object "System.Guid" (, $approver.Get("ObjectGuid"))).ToString()
        $approverName = $approver.Get("name")
        $reportHeader += "<a href='$webInterfaceAddress`#/Browse/$approverGuid'>$approverName</a><br/>"

    $reportHeader += "</td></tr>"

# Build report
$report = $reportHeader + "</table>" + $reportFooter

# Send mail
$Context.SendMail($to, $subject, $NULL, $report)

Comments 2
Rubli Christian Nov 20, 2023
I am using Adaxes version 3.16.21627.0.
Since the upgrade, the link for the authorization no longer works ($webInterfaceAddress`ViewObject.aspx?guid=$requestGuid'>$requestOperation). We receive a web server error (The resource cannot be found,. HTTP404.requested URL: /Adaxes/SelfService/ViewObject.aspx ).
How must the script be adapted so that the users can access the pending authorizations again?
Support Nov 20, 2023
Hello Christian,

Thank you for pointing out the issue. We updated the script and now it generates the correct links in the email notifications.
Leave a comment

Got questions?

Support Questions & Answers