cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
usarif
Resolver I
Resolver I

First, middle name if middle name exist or not

Folks,

   Need little help for variables.

I have a SharePoint list with columns First name, last name, Middle name. Trying to create user in Azure AD uses first name initial, Middle name Initial and last name @Something.com (i use compose for ubstring(triggerBody()?['First_x0020_Name'],0,1)) for upn.

Issue would be if user doesn’t or have middle name. How can create user to put in UPN action in create user.

I was thinking initialize variable on both compose (first, middle)and give same variable name so I can use under user principal name in create user. What are you guys thought?

createuser.png

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
abm
Super User III
Super User III

Hi @usarif 

 

You could try using the below expression.

 

if(equals(length(triggerBody()?['Middle_x0020_Name']),0),concat(triggerBody()?['First_x0020_Name'],triggerBody()?['Last_x0020_Name']),concat(triggerBody()?['First_x0020_Name'],triggerBody()?['Middle_x0020_Name'],triggerBody()?['Last_x0020_Name']))

 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials

View solution in original post

abm
Super User III
Super User III

Hi @usarif 

 

Thanks for the screenshot.

 

It's difficult to debug via expression. So what I would suggest is add three different compose statements. Map firstname, middlename and lastname in each compose. Next add another three compose and add expression length for each compose from the above (firstname, middlename and lastname). Then run your flow and check the run history. This will reveal what exactly parsing under the expression statement. Once all fixed then you can remove all these compose statements.  Hope it make sense.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials

View solution in original post

18 REPLIES 18
abm
Super User III
Super User III

Hi @usarif 

 

Try to use expression not(empty( )) to check middle name exists or not.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials

hi abm,

    thanks for your reply.

 if you look in screen shot below, my flow is getting bigger. I think I can shortened this flow. The reason is because of first and middle init, creating user UPN. if I get user only First and last name then it would be flastname@something.com but adding middle initial making my flow bigger. I think If I setup variable Firstname.middlename.lastname as upn variable and  Firstname.lastname same name variable and then create UPN with that initialize variable. will that work?

 

bigFlow.jpg

Hi @usarif,

 

I think you can use the if() function to determine the middle name whether have, if the length of the middle name is equal to 0, nothing return, or return the middle name:

if(equals(length(triggerBody()?['Middle_x0020_Name']),0),'',triggerBody()?['Middle_x0020_Name'])

If so, you have no need to add the condition action.

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

hi,

  This is what I am getting if middle name not exist. so i am so extracting First Initial from first name and Middle initial (substring(triggerBody()?['First_x0020_Name'],0,1))

middlename.png

abm
Super User III
Super User III

Hi @usarif 

 

The error indicates that middle name is getting null here. 

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials

so how can I handle Null value. That is whole point if middle name exist, compose to initial middle name, and if middle name is blank (which is Null value) UPN would be just FirtnameInitialMiddlenameInitiallastname@something.com, even middle name not exist///

abm
Super User III
Super User III

Hi @usarif 

 

You could try using the below expression.

 

if(equals(length(triggerBody()?['Middle_x0020_Name']),0),concat(triggerBody()?['First_x0020_Name'],triggerBody()?['Last_x0020_Name']),concat(triggerBody()?['First_x0020_Name'],triggerBody()?['Middle_x0020_Name'],triggerBody()?['Last_x0020_Name']))

 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials

View solution in original post

I am getting same error. Because I am leaving Middle name blank so it poping output value Null...

abm
Super User III
Super User III

Hi @usarif 

 

Could you please post your run time history  results where it shows null.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials

 

this is what i am putting under ComposeMiddleExist

if(equals(length(triggerBody()?['Middle_x0020_Name']),0),concat(triggerBody()?['First_x0020_Name'],triggerBody()?['Last_x0020_Name']),concat(triggerBody()?['First_x0020_Name'],triggerBody()?['Middle_x0020_Name'],triggerBody()?['Last_x0020_Name']))

 

Nullvalue.png

abm
Super User III
Super User III

Hi @usarif 

 

Try this in a compose statement as expression

 

if(empty(triggerBody()?['Middle_x0020_Name']),concat(triggerBody()?['First_x0020_Name'],triggerBody()?['Last_x0020_Name']),concat(triggerBody()?['First_x0020_Name'],triggerBody()?['Middle_x0020_Name'],triggerBody()?['Last_x0020_Name']))

 

 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials

I think it is partially working. When  list gets Middlename (means there is a value), I am getting flastname even middlename is empty too. I had change little bit fucntions to get first initial. when I tested with middlename as shown screen shot I am only getting flastname instead fmlastname.
 
if(empty(triggerBody()?['Middle_x0020_Name']),concat(substring(triggerBody()?['First_x0020_Name'],0,1),triggerBody()?['Last_x0020_Name']),concat(substring(triggerBody()?['First_x0020_Name'],0,1),substring(triggerBody()?['Middle_x0020_Name'],0,1),triggerBody()?['Last_x0020_Name']))
 
lastname.jpg
abm
Super User III
Super User III

Hi,

 

Could you please post a screen shot of your flow and run history?

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials

here you go...

 

 

ScreenShot.png

abm
Super User III
Super User III

Hi @usarif 

 

Thanks for the screenshot.

 

It's difficult to debug via expression. So what I would suggest is add three different compose statements. Map firstname, middlename and lastname in each compose. Next add another three compose and add expression length for each compose from the above (firstname, middlename and lastname). Then run your flow and check the run history. This will reveal what exactly parsing under the expression statement. Once all fixed then you can remove all these compose statements.  Hope it make sense.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials

View solution in original post

so I have added as below

composelenghtfirstname.jpg

 

Compose-LenghtFirstname

lenght(outputs('Compose-Firstname'))

ok said it earlier 

length(outputs('Compose-Firstname')) is working fine...what else I can test...
 
composelenghtfirstname.jpg

ok at 12:18 am finally it is working..here what I did, I know there would be other way to do it, but I just don't want to deal anymore.

 

To simplify, I created three compose

1.  substring(triggerBody()?['First_x0020_Name'],0,1)

 

2.  concat(outputs('ComposeFirstNameInit'),triggerBody()?['Last_x0020_Name'])

 

3.  if(empty(triggerBody()?['Middle_x0020_Initial']),outputs('ComposeFlastname'),concat(outputs('ComposeFirstNameInit'),substring(triggerBody()?['Middle_x0020_Initial'],0,1),triggerBody()?['Last_x0020_Name']))

 

composelenghtfirstname.jpg

 

Working fine now..

Helpful resources

Announcements
MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MSFTBizAppsLaunchEvent

Experience what’s next for Power Virtual Agents

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Users online (78,397)