following rule will return identity entitlements 



<?xml version='1.0' encoding='UTF-8'?>

<!DOCTYPE Rule PUBLIC "sailpoint.dtd" "sailpoint.dtd">

<Rule created="1673288180888" id="c0a801c885971783818597bf64980034" language="beanshell" modified="1673676261070" name="customGetUserEntitlements" type="IdentityTrigger">

  <Description>this rule pull entitlements assign to a user.</Description>

  <Signature returnType="boolean">

    <Inputs>

      <Argument name="log" type="org.apache.commons.logging.Log">

        <Description>

          The log object associated with the SailPointContext.

        </Description>

      </Argument>

      <Argument name="context" type="sailpoint.api.SailPointContext">

        <Description>

          A sailpoint.api.SailPointContext object that can be used to query the database if necessary.

        </Description>

      </Argument>

      <Argument name="previousIdentity">

        <Description>

          The identity before the refresh/aggregation (this will be null when an

          identity is created).

        </Description>

      </Argument>

      <Argument name="newIdentity">

        <Description>

          The identity after the refresh/aggregation (this will be null when an

          identity is deleted).

        </Description>

      </Argument>

    </Inputs>

    <Returns>

      <Argument name="result">

        <Description>

          A boolean describing the result of the rule.

        </Description>

      </Argument>

    </Returns>

  </Signature>

  <Source>

  

  import sailpoint.object.Identity;

  import sailpoint.object.QueryOptions;

  import openconnector.rest.Util.QueryFilter;

  import sailpoint.object.Filter;

  import sailpoint.object.IdentityEntitlement;

  

String identityName = "spadmin";

Identity identityObject = context.getObjectByName(Identity.class, identityName);

QueryOptions qoEntUser = new QueryOptions();

Filter f1= Filter.eq("identity", identityObject);

qoEntUser.addFilter(f1);

Iterator identityEntitlements = context.search(IdentityEntitlement.class,qoEntUser);


List allEntsBelongingToUser = new ArrayList();


while(identityEntitlements.hasNext()){


  IdentityEntitlement idEnt = (IdentityEntitlement) identityEntitlements.next();


  allEntsBelongingToUser.add(idEnt.getValue());


}


print("allEntsBelongingToUser::"+allEntsBelongingToUser);

 

  return(allEntsBelongingToUser);</Source>

</Rule>