How to detect current approval level

Which IIQ version are you inquiring about?

8.4

Hi Sailors,

I have created a multilevel approval rule for access request.

Example:

Level 1 (first decision maker) > Level 2 (final decision maker)

The access request is sent to Level 1 first. Once Level 1 approves, it is then routed to Level 2. In my case, Level 2 acts as the final decision maker, meaning the entitlement/role is granted to the identity only if both Level 1 and Level 2 approve.

Due to certain use cases, I need to detect the current approval level. I tried using the code below in my interceptor script, but it always returns Level 2, even though Level 1 has not yet made a decision.

I would like to know if there is a way to correctly detect the current approval level.

Below is my code:

Approval parent = approval.getParent();

    boolean isFirstTier = false;

    if (parent == null) {
        isFirstTier = true;
    }
    else {
        isFirstTier = false;
    }
    System.out.println("Approval tier: " + (isFirstTier ? "Level 1" : "Level 2"));

Try printing approval and share the log

I am using below and it works for me

for (ApprovalItem item : approvalSet.getItems()) {
        if (item == null) {
            continue;
        }

        WorkItem.State state = item.getState();
        System.out.println("Decision = " + state);

    }

is your issue solved?