Hello everyone,
I have a problem executing a javascript code into a task in CA Identity Suite.
The idea of the code is display the 1st letter of the first name, 4 char of the first surname and the 1st letter of the secod surname + the autoincrement number.
When I execute the code displays me only 1 number. It seems like it is not recognizing the adding task.
It would be awesome if someone could help me with this problem.
In addition, i'll share with you the code i text. If someone knows another way to do it in an optimized way please let me know.
Thank you so much,
Daniel Hurtado.
importPackage(java.io);
function handleValidationBeforeSubmission(BlthContext, errorMessage) {
user = BlthContext.getSubject();
up = BlthContext.getUserProvider();
var name= user.getAttribute("%FIRST_NAME%");
var surname1= user.getAttribute("%LAST_NAME%");
var surname2= user.getAttribute("%NAME_ALIAS%");
var num = 1;
var loginopcion8=true;
var opcion8= "";
surname1=surname1.replace(" ","");
while(loginopcion8) {
num = ++num;
opcion8= name.substring(0,1) + surname1.substring(0,4) + surname2.substring(0,1) + num;
opcion8 = opcion8.toLowerCase();
try {
loginopcion8 = up.findUser(null,opcion8,imLoginId);
} catch(NoSuchObjectException) {
loginopcion8 = null;
}
if (loginopcion8 == null)
{
user.setAttribute("%LOGIN_ID%", opcion8);
return true;
}
}
}