How to replace an attributeRequest in before operation rule

Hello everyone

I have a before provisioning rule for a web services connector which evaluates the provisioning plan and according to a certain type of identity when its manager is updated it places a default manager, however the event has another AttributeRequest with the default manager.

Before going through the rule:

<!DOCTYPE ProvisioningPlan PUBLIC "sailpoint.dtd" "sailpoint.dtd">
<ProvisioningPlan nativeIdentity="108305" targetIntegration="Coupa" trackingId="5fcb9b7b23834eeab0d334545656ed82">
  <AccountRequest application="Coupa" nativeIdentity="78" op="Modify">
    <AttributeRequest name="manager" op="Set" value="[email protected]"/>
    <AttributeRequest name="department" op="Set" value="Sales"/>
    <AttributeRequest name="ceco" op="Set"/>
  </AccountRequest>
  <Attributes>
    <Map>
      <entry key="source" value="IdentityRefresh"/>
    </Map>
  </Attributes>
</ProvisioningPlan>

After going through the rule:

<!DOCTYPE ProvisioningPlan PUBLIC "sailpoint.dtd" "sailpoint.dtd">
<ProvisioningPlan nativeIdentity="108305" targetIntegration="Coupa" trackingId="5fcb9b7b23834eeab0d334545656ed82">
  <AccountRequest application="Coupa" nativeIdentity="78" op="Modify">
    <AttributeRequest name="manager" op="Set" value="[email protected]"/>
    <AttributeRequest name="department" op="Set" value="Sales"/>
    <AttributeRequest name="ceco" op="Set"/>
    **<AttributeRequest name="manager" op="Set" value="[email protected]"/>**
  </AccountRequest>
  <Attributes>
    <Map>
      <entry key="source" value="IdentityRefresh"/>
    </Map>
  </Attributes>
</ProvisioningPlan>

The instruction I am using to assign the manager after the validations is:

AttributeRequest newAttReq = new AttributeRequest("manager",ProvisioningPlan.Operation.Set,"[email protected]");
              ar.add(newAttReq);

So what I need to know is if there is any instruction that replaces the value of the manager attribute in the provisioning plan instead of adding it?

Regards.

Rather than adding a new attribute request, iterate over the plan to see if a manager attribute request is already present; if it is, use the setValue() method to update its value.

Hi @jacob_islas - in the Before Rule, remove the original attribute req from the plan 1st, then add the manager one you need.
Example:

List acttReqs = plan.getAccountRequests();


  for(AccountRequest req: attcReqs)

       {

                AttributeRequest attreq = req.getAttributeRequest("manager");

                  if(attreq != null)

                    req.remove(attreq);

What @sunnyajmera mentioned will work as well :slight_smile:

Hi @sunnyajmera

I have placed the set value method but it returns this error:

Error in method invocation: Method setValue(sailpoint.object.ProvisioningPlan$AttributeRequest) not found in class’sailpoint.object.ProvisioningPlan$AccountRequest’ : at Line: 69

This is how it is being sent:

AttributeRequest newAttReq = new AttributeRequest("manager",ProvisioningPlan.Operation.Set,"[email protected]");
              ar.setValue(newAttReq);

AttributeRequest newAttReq = new AttributeRequest(“manager",ProvisioningPlan.Operation.Set,"[email protected]”);

          setValue method is for AttributeRequest. if you have to change the manager, then use setValue() on attributerequest not on accountrequest.

Feel free to share your rule if you are still not clear on how to do this.

1 Like

Hi

With your recommendation I have managed to replace the value of the manager but when I place it in the request to send it to the application’s API, a reference to an object appears. How can I get it to place the value I require?

AttributeRequest newAttReq = new AttributeRequest("manager",ProvisioningPlan.Operation.Set,"[email protected]");
                  at.setValue(newAttReq); //replace manager value

This is the request that is sent to the application API:

payload={
    "department": [{
        "name": "COMPRAS INDIRECTOS"
    }],
    "manager": [{
        "email": "sailpoint.object.ProvisioningPlan$AttributeRequest@66ca74df"
    }],
    "custom-fields": {
                "centro-de-costos-usuario": "1010005"
            }
}, type=PUT, allowedSuccessCodes=[2**], possibleHttpErrorCodes=[], possibleHttpErrorMessages=[]], Returns => {}

I attach the complete rule for further reference

rule.txt (6.0 KB)

Regards

What is the source of the manager attribute?
If it is coming from an identity attribute via attribute sync, then a transformation rule might be.a better place for the logic you are implementing.