How can i get the value of the nativeIdentity in my Provisioning Plan using a Before Operation Rule?

Which IIQ version are you inquiring about?

8.1

Hello! I’m trying to create a Before Operation Rule that requires having one attribute that appears in my Provisioning Plan as a “NativeIdentity.”

I’ve tried many methods and wasn’t able to retrieve that attribute value in any of my attempts.

This is my Provisioning Plan:

<ProvisioningPlan nativeIdentity="901514792" targetIntegration="JANIS" trackingId="7594e48c3d5a4837b16d8c01a7590047">
  <AccountRequest application="JANIS" nativeIdentity="[email protected]" op="Modify">
    <Attributes>
      <Map>
        <entry key="comments" value="teste"/>
      </Map>
    </Attributes>
    <AttributeRequest name="profileId" op="Remove" value="646bc984825d7f880405ba93">
      <Attributes>
        <Map>
          <entry key="allowSimplification" value="true"/>
          <entry key="assignment" value="true"/>
          <entry key="preferRemoveOverRetain" value="true"/>
        </Map>
      </Attributes>
    </AttributeRequest>
  </AccountRequest>
  <Attributes>
    <Map>
      <entry key="identityRequestId" value="0000014290"/>
      <entry key="requester" value="901525699"/>
      <entry key="source" value="LCM"/>
    </Map>
  </Attributes>
</ProvisioningPlan>

All I need is to store the value of nativeIdentity in a variable that will be used further in the logic I’m working on.

Can someone show me some method that i can use to retrive that data as i wanted to? Thanks a lot.

Hi @diego_romero_1 ‘plan’ is the one of default argument for BeforeProvisioning rule, hence you can get the native identity of plan as below.

If you want to get the nativeIdentity of Account Request, then you need to iterate the plan’s account requests.

@diego_romero_1 ,
You can use the below code for getting the value from AccountRequest.

import sailpoint.object.ProvisioningPlan.AccountRequest;
  import sailpoint.object.ProvisioningPlan.AccountRequest.Operation;
  import sailpoint.object.ProvisioningPlan.AttributeRequest;
  import sailpoint.object.ProvisioningPlan.ObjectOperation;
  import sailpoint.object.ProvisioningPlan.Operation;
 
  List accRequests = plan.getAccountRequests("APP_NAME");
  for ( AccountRequest accReq : accRequests )
  {
    if ( accReq.getOp() == ObjectOperation.Modify ) // You can use or check the operation whatever you want
    {
      if(null != accReq.getNativeIdentity()){
        String nativeId = accReq.getNativeIdentity();
      }
    }
  }

I tried using this code and receive that error bellow:

Error executing before operation rule for endpoint ‘Disable Account’: BeanShell script error: bsh.EvalError: Sourced file: inline evaluation of: import java.util.Map; import java.util.concurrent.TimeUnit; import sailpoint.o . . . '' : Typed variable declaration : Attempt to resolve method: getAccountRequests() on undefined variable or class name: plan : at Line: 17 : in file: inline evaluation of: import java.util.Map; import java.util.concurrent.TimeUnit; import sailpoint.o . . . ‘’ : plan .getAccountRequests ( “jani” ) BSF info: LOG-Teste Disable Janis at line: 0 column: columnNo

Apparently the “plan” class is not available using a Before Operation Rule.

I can’t access the plan this way, I keep getting an error as if this method was not valid.

Use provisioningPlan instead of plan and try once.

I’ve just tried your code with the “provisioningPlan,” but I noticed that the nativeId variable isn’t being declared.

I added some logs to verify if the logic was going through the if statements, and it is. The problem seems to be that nativeId is never actually declared.

2024-12-20T10:51:40,953 WARN https-jsse-nio-443-exec-31 sailpoint.server.InternalContext:166 - Got to accReq.getOp() == ObjectOperation.Modify
2024-12-20T10:51:40,953 WARN https-jsse-nio-443-exec-31 sailpoint.server.InternalContext:166 - Got to null != accReq.getNativeIdentity()
2024-12-20T10:51:40,954 WARN https-jsse-nio-443-exec-31 sailpoint.server.InternalContext:166 - #nativeId value: #
2024-12-20T10:51:40,954 WARN https-jsse-nio-443-exec-31 sailpoint.server.InternalContext:166 -

Use the String nativeId = “”; as global variable and use out side of if or for loop and try once.

I’ve tried this already, this is the code i’m using right now:

import sailpoint.object.ProvisioningPlan.AccountRequest;
import sailpoint.object.ProvisioningPlan.AccountRequest.Operation;
import sailpoint.object.ProvisioningPlan.AttributeRequest;
import sailpoint.object.ProvisioningPlan.ObjectOperation;
import sailpoint.object.ProvisioningPlan.Operation;
import org.apache.log4j.Logger;
import org.apache.log4j.Level;
import java.util.concurrent.TimeUnit;


log.warn("Aguardando 10 segundos.");
TimeUnit.SECONDS.sleep(10);

String nativeId = "";

List accRequests = provisioningPlan.getAccountRequests("JANIS");
for ( AccountRequest accReq : accRequests ) {
    if ( accReq.getOp() == ObjectOperation.Modify ) {
        log.warn("Cheguei em ObjectOperation.Modify");
        if(null != accReq.getNativeIdentity()) {
            log.warn("Cheguei em accReq.getNativeIdentity");
            String nativeId = accReq.getNativeIdentity();
        }
    }
}

log.warn("#nativeId#");
log.warn(nativeId);

Don’t use this statement again String nativeId = accReq.getNativeIdentity();

just use: nativeId = accReq.getNativeIdentity();
Because you already declared above. You just to have assign value to that.

It worked, but i didn’t get the value i expected.

The code assigned the value “[email protected]” for nativeId, but i was expecting to get “901514792”.

<ProvisioningPlan nativeIdentity="901514792" targetIntegration="JANIS" trackingId="7594e48c3d5a4837b16d8c01a7590047">
<AccountRequest application="JANIS" nativeIdentity="[email protected]" op="Modify">

Is there a way to get the nativeIdentity directly from the Provisioning Plan insted of getting from AccountRequest?

I really appreciate your help until now.

Yes, we have method in the ProvisioningPlan class: getNativeIdentity()
You can use this one to get that value.
String nativeId = provisioningPlan.getNativeIdentity();

1 Like

It worked, thank you a lot for all the help.

I wish you and your entire family an excellent end of the year.

2 Likes

You are welcome, @diego_romero_1 . Happy to help :+1:.
Thank you. I wish you a happy new year in advance.