I am trying to access the identity to update the link that was just created but keep getting errors when trying to access the identity. I am hoping to add an attribute on the link in iiq that is returned from the account create action.
Here are a couple of tries and the errors they are throwing
import sailpoint.api.IdentityService;
IdeneityService idnSrv=new IdeneitService(context);
List linkList=idnSrv.getLinks(My_app,identity); //identity should be identity Object, i guess it coming as an input argument in you rule.
for(Link link : linkList){
if(link!=null) {
log.error("xxx here is my link " + myLink);
} else {
log.error("xxx i did not get a link);
}
}
If identity is there in argument of the after ProvisioningRule then you do not need below line
Are you trying to get the identity on the WebServiceAfterOperationRule ? if so that rule doesnt have identity as the default argument. you need to retrieve the username from the response or from the payload and use context to fetch the identity.
i see the identity is not a default argument for the rule. that why is your are getting the earlier error of void intialization and undefined variable.
Agree to @chaitanyav, I can see Application is available as default argument in after rule so you need not to create application object, you will have to retrieve the userName from rawResponseObject and then create an identity object to get its links.
Once identity object is created you can use identityService to get the Links for specific application.
Giving this a try after working out some other issues and getting the error below. Is there a better way to do the identity search? I am getting the data back from the user create.
Caused by: org.apache.bsf.BSFException: BeanShell script error: bsh.EvalError: Sourced file: inline evaluation of: ``import java.text.ParseException; import java.text.SimpleDateFormat; import sai . . . ‘’ : Typed variable declaration : Class: IdentityQuery not found in namespace
This is how I am trying it
import sailpoint.object.IdentityQuery;
import sailpoint.api.SailPointContext;
log.error("xxx data returned " + id + ", " + loginId);
SailPointContext context = sailpoint.api.SailPointFactory.getCurrentContext();
IdentityQuery identityQuery = context.getObject(IdentityQuery.class);
identityQuery.addFilter("theId", loginId);
List matchingIdenties = identityQuery.getResultList();
for(Identity identity : matchingIdentities) {
log.error("xxx here are the identities: " + identity.getId());
}
Can you be more specific with the requirement?
If you are trying to add an additional attribute in the application account (Link) which you are getting from Create Account response, try using Response Mapping in Create account operation.
The app config looks good, A similar setup is working properly in my Sandbox setup. I could see there is an AfterRule attached what is it exactly doing? Also verify the data using BeforeRule and AfterRule which will give you better understanding on the data being send, received and how IIQ is processing it.
BEfore rule is currently printing out the data being sent
log.error("Staring before operation rule");
Map body = requestEndPoint.getBody();
log.error("body value is : "+body);
String jsonBody = (String) body.get("jsonBody");
log.error("jsonBody value is : "+jsonBody);
Map jsonMap = JsonUtil.toMap(jsonBody);
log.error("jsonMap value is:"+jsonMap);
log.error("Ending before operation rule");
after rule was going to be used to grab the response and update the identity
all it does now is print out the data being returned
log.error("xxx Starting after operation rule");
log.error("xxx rawResponseObject " + rawResponseObject);
String jsonResponse = rawResponseObject.toString();
log.error("xxx jsonResponse " + jsonResponse);
JSONObject jsonObject = new JSONObject(jsonResponse);
log.error("xxx jsonObject " + jsonObject);
//access the id value
int id = jsonObject.getJSONObject("record").getInt("id");
String loginId = jsonObject.getJSONObject("record").getString("loginId");
log.error("xxx data returned " + id + ", " + loginId);
log.error("xxx Ending after operation rule");