Getting Last Name from a Username value

  • 19 October 2017
  • 1 reply
  • 3 views

  • Anonymous
  • 0 replies

Hello All,

 

 

 

 

Sometimes AD puts usernames/display names in a format that is not the easiest to use. Something like Doe, John can be hard to get just the last or first name. We can use expressions to strip off the first name or last name. 

 

 

 

 

 

Let's say we have a Display Name Property like Manning, Peyton. We only want to get Manning from this. We will use the Left and Find expressions to create this. I am using a simple Text Box to hold my values. 

 

 

 

 

 

It would looke something like this:

 

 

Left ( [Text Box Control] , Find ( [Text Box Control] , [,] ) - 1 )

 

 

 

 

 

We will break this down from the inside out:

 

 

 

 

 

We use the Find Operator (Found in the Text folder of Operators) to search for the comma. This gives us a Integer for where the comma is located, which we can then use to split in the Left expression. We need the to subtract 1 (Subtraction sign found in Operators folder) to take out the comma character as well.

 

 

 

 

 

It looks like below:

 

 

Find ( [Our Control], [comma character] ) -1.

 

 

 

 

 

Once we have our length from which we will take the Left, we can plug this into our Left function. 

 

 

Left ( [Our Control] , [Find Function Above] ) 

 

 

 

 

 

It looks like below in the expression builder.

 

 

14391i3E3F314247B8F49E.png

 

 

 

 

 

 

 

 

We can use this same idea to strip out Usernames from an email address, targeting the @ character as our comma character. We can also grab the first name with the same idea. 

 


1 reply

Badge +6

Hi MTMTNT,


 


Thanks for this post, I found it very helpfull.


 


Kind Regards,


 


Nicolaas Swart

Reply