Skip to main content
Community site session details

Community site session details

Session Id : FYKvAqlbhkBgEDl5Lp1278
Power Automate - Building Flows
Answered

First, middle name if middle name exist or not

Like (0) ShareShare
ReportReport
Posted on 5 Dec 2019 22:11:25 by 195

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

 

  • usarif Profile Picture
    195 on 11 Dec 2019 at 06:22:21
    Re: First, middle name if middle name exist or not

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

  • usarif Profile Picture
    195 on 11 Dec 2019 at 04:02:25
    Re: First, middle name if middle name exist or not

    ok said it earlier 

    length(outputs('Compose-Firstname')) is working fine...what else I can test...
     
    composelenghtfirstname.jpg
  • usarif Profile Picture
    195 on 11 Dec 2019 at 03:48:26
    Re: First, middle name if middle name exist or not

    so I have added as below

    composelenghtfirstname.jpg

     

    Compose-LenghtFirstname

    lenght(outputs('Compose-Firstname'))
  • Verified answer
    abm abm Profile Picture
    32,506 Most Valuable Professional on 10 Dec 2019 at 14:57:09
    Re: First, middle name if middle name exist or not

    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

  • usarif Profile Picture
    195 on 10 Dec 2019 at 14:37:30
    Re: First, middle name if middle name exist or not

    here you go...

     

     

    ScreenShot.png

  • abm abm Profile Picture
    32,506 Most Valuable Professional on 10 Dec 2019 at 09:29:32
    Re: First, middle name if middle name exist or not

    Hi,

     

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

     

    Thanks

  • usarif Profile Picture
    195 on 10 Dec 2019 at 06:03:17
    Re: First, middle name if middle name exist or not
    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 abm Profile Picture
    32,506 Most Valuable Professional on 09 Dec 2019 at 22:57:04
    Re: First, middle name if middle name exist or not

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

     

     

  • usarif Profile Picture
    195 on 09 Dec 2019 at 22:52:56
    Re: First, middle name if middle name exist or not

     

    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 abm Profile Picture
    32,506 Most Valuable Professional on 09 Dec 2019 at 22:37:03
    Re: First, middle name if middle name exist or not

    Hi @usarif 

     

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

     

    Thanks

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 2

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 2

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 2

Loading complete