0 votes

Is it possible to craft a Business Rule that would send an email notification only if the request for an action was denied?

Thanks

by (950 points)

1 Answer

0 votes
by (18.0k points)

Update 2018

Starting with Adaxes 2018.1, Adaxes automatically sends email notifications to approvers and the operation initiator when an approval request is denied. For details on configuring the notifications, have a look at the following help article: https://www.adaxes.com/help/CustomizeEmailNotifications.

Original

Hello Brad,

By default, Adaxes sends a notification to the operation initiator when the operation is denied.
Unfortunately it is impossible to create a Business Rule that will send a notification when a request is rejected.
However, you can create a Scheduled Task that will execute a script that will send email notifications for all requests rejected during the last hour/day/month.
We can implement such a script for you.

0

It would be great to see an example script.

Thanks

0

No problem.

$Hours = 24 # TODO: must depend on the schedule of the task

$admNS = New-Object("Softerra.Adaxes.Adsi.AdmNamespace")
$admService = $admNS.GetServiceDirectly("localhost")

function SendNotification($approval)
{
    $to = "%mail%"
    if ([System.String]::IsNullOrEmpty($to))
    {
        $Context.LogMessage("Email address is empty!", "Error")
        return
    }
    $subject = "My Subject"
    $bodyText = $NULL
    $requestorName = $approval.Requestor.Get("name")
    $deniedBy = $approval.ProcessedBy.Get("name")
    $operation = $approval.DescriptionOfOperationToApprove
    $reason = $approval.DenialOrCancelingReason
    $bodyHtml = @"
Requestor: $requestorName<br />
Denied by: $deniedBy<br />
Reason: $reason<br />
Operation: $operation<br />
"@
    $Context.SendMail($to, $subject, $bodyText, $bodyHtml)
}
# Bind to the Approval Requests container
$approvalsPath = $admService.Backend.GetConfigurationContainerPath("ApprovalRequests")
$aprovalsContainer = $admService.OpenObject($approvalsPath.ToString(), $NULL, $NULL, 0)
# Get all denied approval requests
$aprovals = $aprovalsContainer.GetApprovalRequests("ADM_APPROVALSTATE_DENIED")

foreach ($requestID in $aprovals)
{
    # Bind to the approval request
    $guid = New-Object "System.Guid" (,$requestID)
    $guid = $guid.ToString("B")
    $approvalsPath = "Adaxes://<GUID=$guid>"
    $approval = $admService.OpenObject($approvalsPath, $NULL, $NULL, 0)

    # Check whether the request was modified during the last N hours
    $modificationDate = $approval.Get("whenChanged");
    if ([System.DateTime]::Now -gt $modificationDate.AddHours($Hours))
    {
        continue
    }

    SendNotification($approval)
}
  1. Open the PowerShell script in a text editor and customize it for your needs (2012.1 will introduce an embedded PowerShell script editor).
  2. Launch Adaxes Administration Console.
  3. Run the Scheduled Task Creation wizard.
  4. On the 3rd step of the wizard select the User object type.
  5. On the 4th step, click Add Action.
  6. Select the Run a program of PowerShell script action.
  7. Paste the script to the Script edit box, click OK, and then click Next.
  8. On the 5th step of the wizard, click Add.
  9. In the dialog that opens select the User object type in the Object Types drop-down dialog.
  10. In the list of available objects, select the users you want to receive email notifications.
  11. Click OK and then click Finish.

That's it :) Little bit tricky, but works.

Related questions

0 votes
1 answer

This may be a stupid question but I'm looking to create an approval process for users being added to sensitive AD groups such as the domain admins group. How would I ... to use especially since the condition is based on changes that have not yet happened...

asked Nov 1, 2012 by VTPatsFan (610 points)
0 votes
1 answer

We want to workflow approve additions to certain groups, but not deletions from them. When you add a group to a group, is it possible to perform workflow approval for this? ... Not sure that we want to use the more general "Before Updating a Group" option.

asked Apr 12, 2012 by BradG (950 points)
0 votes
1 answer

I have a scheduled task that runs a custom command that itself has multiple custom commands that run in a specific timed order. I would like the scheduler to run that top level ... , but Command B and C will wait for Command A to finish. Is this possible?

asked Jul 23 by DA-symplr (100 points)
0 votes
0 answers

WorkFlow : From Adaxes, how can the Director or Assistant validate the employee’s "Job Title" modification request?

asked Jul 12, 2023 by LucasGrd (40 points)
0 votes
1 answer

Do you include options for complex workflows? Such as API or csv/tsv files from ADP and other companies for automated provisioning and de-provisioning users based on their work status?

asked Jul 19, 2022 by gdillenbec (20 points)
3,548 questions
3,239 answers
8,232 comments
547,814 users