web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / First, middle name if ...
Power Automate
Answered

First, middle name if middle name exist or not

(0) ShareShare
ReportReport
Posted on by 220

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 @Anonymous.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

 

Categories:
I have the same question (0)
  • abm abm Profile Picture
    32,928 Most Valuable Professional on at

    Hi @usarif 

     

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

     

    Thanks

  • usarif Profile Picture
    220 on at

    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

  • v-litu-msft Profile Picture
    on at

    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.

  • usarif Profile Picture
    220 on at

    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 abm Profile Picture
    32,928 Most Valuable Professional on at

    Hi @usarif 

     

    The error indicates that middle name is getting null here. 

     

    Thanks

  • usarif Profile Picture
    220 on at

    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///

  • Verified answer
    abm abm Profile Picture
    32,928 Most Valuable Professional on at

    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']))

     

  • usarif Profile Picture
    220 on at

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

  • abm abm Profile Picture
    32,928 Most Valuable Professional on at

    Hi @usarif 

     

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

     

    Thanks

  • usarif Profile Picture
    220 on at

     

    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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 223 Super User 2025 Season 2

#2
Expiscornovus Profile Picture

Expiscornovus 205 Most Valuable Professional

#3
harshdeol Profile Picture

harshdeol 167 Moderator

Last 30 days Overall leaderboard