Extracting a User's First Name from a Field using UpDatedBy()
I need to send an email to a user who has updated a record.... and I wanted to start by Dear 'First Name'.
I can use a field with the UpdatedBy() expression to get their full name, but this was not appropriate.
So, I built an expression to extract the First Name.
This required me identifying the first space in the string returned by UpdatedBy(), and using Substring to extract the characters upto the space. To do this I use a Person Field "UpdatedBy" that uses the expression UpdatedBy(), with the _Text at the end, it returns the name of the user in Text.
In excel, I'd use Find, but we don't have Find in Softools. So, I "invented" by own Find expression.
The expression "if(Substring([UpdatedBy_Text],14,1)=' ',14,0)" returns 14 if there is a space at position 14, otherwise it returns 0... and the expression "if(Substring([UpdatedBy_Text],13,1)=' ',13,if(Substring([UpdatedBy_Text],14,1)=' ',14,0))" returns 13 when the space is a position 13 or 14 if the space is at position 14.
To get the position (upto position 14), the expression
if(Substring([UpdatedBy_Text],2,1)=' ',2,if(Substring([UpdatedBy_Text],3,1)=' ',3,if(Substring([UpdatedBy_Text],4,1)=' ',4,if(Substring([UpdatedBy_Text],5,1)=' ',5,if(Substring([UpdatedBy_Text],6,1)=' ',6,if(Substring([UpdatedBy_Text],7,1)=' ',7,if(Substring([UpdatedBy_Text],8,1)=' ',8,if(Substring([UpdatedBy_Text],9,1)=' ',9,if(Substring([UpdatedBy_Text],10,1)=' ',10,if(Substring([UpdatedBy_Text],11,1)=' ',11,if(Substring([UpdatedBy_Text],12,1)=' ',12,if(Substring([UpdatedBy_Text],13,1)=' ',13,if(Substring([UpdatedBy_Text],14,1)=' ',14,0)))))))))))))
works perfectly !
So plugging that into another expression, gives me the First Name
Substring([UpdatedBy_Text], 0, if(Substring([UpdatedBy_Text],2,1)=' ',2,if(Substring([UpdatedBy_Text],3,1)=' ',3,if(Substring([UpdatedBy_Text],4,1)=' ',4,if(Substring([UpdatedBy_Text],5,1)=' ',5,if(Substring([UpdatedBy_Text],6,1)=' ',6,if(Substring([UpdatedBy_Text],7,1)=' ',7,if(Substring([UpdatedBy_Text],8,1)=' ',8,if(Substring([UpdatedBy_Text],9,1)=' ',9,if(Substring([UpdatedBy_Text],10,1)=' ',10,if(Substring([UpdatedBy_Text],11,1)=' ',11,if(Substring([UpdatedBy_Text],12,1)=' ',12,if(Substring([UpdatedBy_Text],13,1)=' ',13,if(Substring([UpdatedBy_Text],14,1)=' ',14,0))))))))))))))
Please sign in to leave a comment.
Comments
0 comments