Skip to main content

Notifications

Power Automate - Building Flows
Answered

First, middle name if middle name exist or not

Posted on 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
    usarif 195 on at
    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
    usarif 195 on at
    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
    usarif 195 on at
    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
    abm abm 32,194 on at
    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
    usarif 195 on at
    Re: First, middle name if middle name exist or not

    here you go...

     

     

    ScreenShot.png

  • abm abm Profile Picture
    abm abm 32,194 on at
    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
    usarif 195 on at
    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
    abm abm 32,194 on at
    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
    usarif 195 on at
    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
    abm abm 32,194 on at
    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

October 2024 Newsletter…

October 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #4 How to Conntact Support…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 142,473

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 63,659

Leaderboard