Setting the Approved\Rejected for each individual item in WorkItem User Notification Email

Which IIQ version are you inquiring about?

IIQ 8.3p3

Share all details about your problem, including any error messages you may have received.

Hello everyone!

We’ve encountered this problem with the logic in our custom email templates.
Currently we’re sending the notification to users with the table of all requested roles and trying to set the approval result (approved or rejected) for each individual work item.
Using the default $approvalSet.hasApproved() and $approvalItem.hasRejected() will only give us the result for the first role in the approvalItem. A. e. if the user requested two roles and the first of them was approved and the second rejected, both of them will be “Approved” in the table.

Here’s the part of the code we use in the email template:

#if ( $approvalSet.hasApproved() || $approvalSet.hasRejected())
<p>Dear $identityDisplayName,</p>
        <p>All stages of the authorization request have been executed:</p>
        <table class="table">
            <tr>
                <th>Action</th>
                <th>Result</th>
                <th>Application</th>
                #if ($item.nativeIdentity) <th>Account</th> #end
                <th>Attribute</th>
                <th>Value(s)</th>
                <th>Comments</th>
            </tr>
            #foreach ($item in $approvalSet.items)
            <tr>
                <td>$item.operation</td>
                <td>#if ($approvalSet.hasApproved()) 
							Approved
						#else 
							#if ($approvalSet.hasRejected()) 
								Rejected
							#else 
								Cannot calculate
							#end
				#end</td>
                <td>$item.applicationName</td>
                #if ($item.nativeIdentity) <td>$item.nativeIdentity</td> #end
                <td>#if ($item.displayName) $item.displayName #else $item.name #end</td>
                <td>#if ($item.displayValue) $item.displayValue #else $item.csv #end</td>
                <td>#foreach ($comment in $item.comments) $comment #end</td>
            </tr>
            #end
        </table>

Does anyone know how to deal with resolving the approval result for each of the roles? Or maybe some other way to make this table based on the approval set result?

Thanks in advance!

Best Regards,
Danylo

To resolve the issue where the same approval result is being applied to all items in the table instead of differentiating between each individual role’s approval status, you should focus on applying the logic at the individual $item level rather than at the $approvalSet level. The issue arises because you’re checking approval status for the whole approval set instead of each approval item individually.

#if ( $approvalSet.hasApproved() || $approvalSet.hasRejected())
    <p>Dear $identityDisplayName,</p>
    <p>All stages of the authorization request have been executed:</p>
    <table class="table">
        <tr>
            <th>Action</th>
            <th>Result</th>
            <th>Application</th>
            #if ($item.nativeIdentity) <th>Account</th> #end
            <th>Attribute</th>
            <th>Value(s)</th>
            <th>Comments</th>
        </tr>
        #foreach ($item in $approvalSet.items)
        <tr>
            <td>$item.operation</td>
            <td>
                #if ($item.hasApproved()) 
                    Approved
                #elseif ($item.hasRejected()) 
                    Rejected
                #else 
                    Cannot calculate
                #end
            </td>
            <td>$item.applicationName</td>
            #if ($item.nativeIdentity) <td>$item.nativeIdentity</td> #end
            <td>#if ($item.displayName) $item.displayName #else $item.name #end</td>
            <td>#if ($item.displayValue) $item.displayValue #else $item.csv #end</td>
            <td>#foreach ($comment in $item.comments) $comment #end</td>
        </tr>
        #end
    </table>
#end
1 Like

Hello Adam,

Thank you for the reply.
I’ve tried it previously and tried one more time the result we get in the email is always “Cannot calculate”

Thanks

Hej Danylo,

on ApprovalSet you can use hasApproved();
on ApprovalItem you should use isApproved();

Br,
Renad

1 Like

Hi Renad,

Thank you a lot, that helped!