Skip to main content
December 20, 2024
Question

How to fetch username out of Email address

  • December 20, 2024
  • 8 replies
  • 0 views

Hi fellow devs,

There is a scenario where I have email address available to me like: "testuser@gmail.com" and this email address has some username at the backend like this: "Test_user".

Now what I want to do is on the basis of email I want to fetch username. Previously I was using this function to fetch username out of email address:

index(getusersby(pv!ccperson,3,1),1, null)

(this function gives output in expression rule but in process model don't know why its not working and gives error)

but now it seems like this function is no longer working. I am unable to find any other function through which I can perform this functionality, any help in this regard would be helpful.

8 replies

jayaprakashr0001
Participating Frequently
December 20, 2024

HI [mention:f5fdf61a09d64f5281127ef64d6d81d4:e9ed411860ed4f2ba0265705b8793d05] ,

Where are getting this email address. Because the function you gave is working fine. 

Please check how many users are created on the same email.

Try the below code

a!localvariables(
local!email:"testuser@gmail.com",
local!userDetails:index(getusersby(local!email,3,1),1,null),
  user(local!userDetails,"firstName")
  )

December 20, 2024

Yes it works in the expression rule but in process model its not working. the process model starts as a result of email received. Like e.g:  I send email from my outlook to initiate the process model by mailing to processmodel26840@snldev.appiancloud.com as a result in the process model there is one process variable "from" of type text that receives email id of the sender i.e: me as sadia@test.com so in the script task i am using this "from" process variable to fetch username out of it using this getusersby() but it seems like "from" process variable is getting passed as empty.

mikes0011
Brainy
December 20, 2024
it seems like "from" process variable is getting passed as empty

That seems like a completely separate issue though.  Your initial post makes the assumption that we are starting with a known initial address and needing to find the associated user. 

But this addition makes it sound like it's not even getting as far as getting the initial email, meaning it's not even about finding the associated user account, but perhaps a configuration or execution issue related to how your process is getting launched.

gayatria0439
December 20, 2024

Hi [mention:f5fdf61a09d64f5281127ef64d6d81d4:e9ed411860ed4f2ba0265705b8793d05] ,

Yes, you can use the user() function by passing the email ID as an argument. This will allow you to retrieve first name, middle name, last name, display name (the user's nickname), supervisor name, title, email, office phone, mobile phone, home phone, address lines 1-3, city, state, province, zip code, country, locale, time zone, custom fields 1-10, UUID, creation date, status, user type ID, and user type name. However, please note that the exact username cannot be retrieved using this function. Regarding the getUsersBy() function, I am unable to obtain the expected output while using this function am also looking for the solution.

mathieud0001
December 20, 2024

You could use the built-in User Record instead

December 20, 2024

will it work if in value instead of hardcoded value i pass process variable that has email id? its not working in that case.

mathieud0001
December 20, 2024

Yes, why would it not?