Script repository
The script sends the list of pending approval requests for the operations initiated by the targget user to the specified recipients. To execute the script, create a business rule, custom command or scheduled task configured for the User object type.
Parameters
$to- the email address of the notification recipient.$subject- the email notification subject.$reportHeader- the email notification header.$reportFooter- the email notification footer.
$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">
<tr>
<th>Request</th>
<th>Approvers</th>
</tr>
"@ # 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))
{
return
}
# Get all the pending requests initiated by the user.
$requests = $Context.TargetObject.GetRequestsForApproval("ADM_APPROVALSTATE_PENDING")
if ($requests.Length -eq 0)
{
return
}
# Get the web interface address specified for 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>"
}
# Send mail
$report = $reportHeader + "</table>" + $reportFooter
$Context.SendMail($to, $subject, $NULL, $report)
Comments 2
You must be signed in to comment.
Rubli Christian
Hi,
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
Hello Christian,
Thank you for pointing out the issue. We updated the script and now it generates the correct links in the email notifications.