How can I fetch the entitlements a user has requested

How can I get details about the entitlements a user has requested for from the LCM provisioning workflow using the IdentityRequest object?

I tried fetching the IdentityRequest object using the IdentityRequestId variable, however I can’t access the entitlements value or even the requester name. How can I do this?

Hi Wadu,

You first get the identityrequest object. Identity request object has multiple object referenced in it. For that I will need recommend you going through the javadoc and you can see how you can retrieve all those details.

Eg: identityrequest object has provisioning project which can be used to fetch the required detailsm

Hi @waduhek ,

By using the identityRequestId variable in LCM Provisioning, you can get the IdentityRequest object and then get the requester name from IdentityRequest object and requested entitlements from IdentityRequestItem object.

you can use below sample code to retrieve the requester name and requested entitlements from the IdentityRequest object.

import org.apache.log4j.Logger;
import sailpoint.object.IdentityRequest;
import sailpoint.object.IdentityRequestItem;

import java.util.List;
import java.util.ArrayList;

String targetDisplayName;
String requesterDisplayName;

List requestedItems = new ArrayList();

if(identityRequestId!=null){

IdentityRequest  identityrequest = context.getObjectByName(IdentityRequest.class,identityRequestId);

if(identityrequest!=null){

  if(identityrequest.getTargetClass().equalsIgnoreCase("Identity")){

    targetDisplayName = identityrequest.getTargetDisplayName(); // Gives of the displayname of requestee

    requesterDisplayName = identityrequest.getRequesterDisplayName();// Gives of the displayname of requester

     requestedItems =  identityrequest.getItems();

    if(requestedItems!=null && !requestedItems.isEmpty()){

      for(IdentityRequestItem identityRequestItem : requestedItems){

        if(identityRequestItem!=null){

          String value = identityRequestItem.getValue(); // gives native identity of requested entitlement

          log.info("Request Entitlement: " + value);

          log.info("requesterDisplayName  : " + requesterDisplayName);

        }

      }

    }

  }
}

}


1 Like

This is exactly what I was looking for. Thank you!

Glad to hear it helped!

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.