Venu1010
(Venugopala Hs)
August 14, 2024, 2:16pm
1
Hi All,
I have to validate and send available email for robotic ID. I have prepared the logic but getting error. Could anyone please help here. Really appreciate.
Email format : firstName+“.”+“DW”+"@org.com ";
example : [email protected]
If [email protected] already in use. It should concatenate firstName with 1 and go on. like [email protected]
Email Checking.java (1.3 KB)
Hi @Venu1010 ,
I have just tested the below code now and it should give you the required result.
import sailpoint.tools.Util;
import java.text.Normalizer;
import sailpoint.object.Filter;
import sailpoint.object.Identity;
import sailpoint.object.QueryOptions;
import sailpoint.api.SailPointContext;
int counter = 0;
boolean isExisting = true;
String firstName = "Orange";
String lastName = "DW";
String email = null;
while(isExisting)
{
QueryOptions queryOptions = new QueryOptions();
counter == 0 ? (email = firstName + "." + lastName + "@sunlife.com") : (email = firstName + counter + "." + lastName + "@sunlife.com");
queryOptions.addFilter(Filter.eq("email", email));
if(context.countObjects(Identity.class, queryOptions) != 0)
{
counter++;
continue;
}
isExisting = !isExisting;
}
return email;
Thanks,
2 Likes
vedeepak
(Deepak Vema)
August 14, 2024, 2:38pm
3
Can you try below code?
String newEmailID =emailID;
int nameIndex = newEmailID.indexOf('.');
int domainIndex = newEmailID.indexOf('@');
String firstName = newEmailID.substring(0, nameIndex);
String lastName = newEmailID.substring(nameIndex + 1, domainIndex);
String domain = newEmailID.substring(domainIndex);
int count = 1;
String newEmailName = firstName + count + "." + lastName + domain;
while (isEmailInUse(newEmailName)) {
count++;
newEmailName = firstName + count + "." + lastName + domain;
}
emailID = newEmailName;
isEmailInUse is a method the way you are searching in Identity Class. May be you can place searching code inside this method.
Hope this helps
1 Like
system
(system)
Closed
October 13, 2024, 2:38pm
4
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.