I’m trying to fetch all accounts from a source for a usecase, and i have come through below method.
getAllAccounts(java.lang.String applicationName, java.lang.String identityName) from idnRuleUtil.
Does it return all accounts from a source if I provide null in the place of identityName.
Okay, is there any work around to get all accounts of a source. I’m trying to fetch recently created account’s employee number, so that i can increment it and return new employee number.
So, tell me if I have understood your use-case clearly.
On creation of user on an application, you are assigning an employee number. For that you are comparing the created employee number with all the other accounts. Am I right? Also, what’s the rule you are using for it?
I am just thinking it on another way. As I can’t find anyway for getting all accounts from an application.
Even, once an account is going to be created in IDN, it’s going to calculate an Identity Attributes, where you are going to use this rule on creating Employee Number.
So, using the below snippet, you get the applicationName. This is because, to avoid getting values from identity attributes. Here, we use account attributes to calculate the values needed - best practise.
List links = identity.getLinks();
String applicationName, nativeIdentity;
String authoritativeSourceId = "" //HR App ID;
if (!Objects.isNull(links)) {
for (Link link: links) {
if (link.getApplicationId().equals(authoritativeSourceId)) {
applicationName = link.getApplicationName();
nativeIdentity = link.getNativeIdentity();
}
}
}
String firstName; //Initialize the variables you need
if (!Objects.isNull(idn.getAccountAttribute(applicationName, nativeIdentity, "First Name"))) {
firstName = idn.getAccountAttribute(applicationName, nativeIdentity, "First Name");
}
/*
you can also use,
if (!Objects.isNull(identity.getAttribute("firstname"))) {
firstName = identity.getAttribute("firstname");
}
This method can be avoided as this is going to be executed while creation itself.
*/
// After this you may give your condition to start the script.
Sorry, that I missed to mention the employee number needs to be calculated during identity creation and the new number will be based on recently created identity’s employee number.
So, I need to fetch recently created account from the HR source.