Skip to main content

Notifications

Power Automate - Building Flows
Answered

Filter empty BusinessPhones and change BusinessPhones to string

Posted on by 6
Hello,
 
I am trying to get the business phones from Office 365 and return a list on SharePoint. 
 
I would like to filter out those users without business phone.
 
Example of the output of 'Search for users (V2)' (no BusinessPhones):
{
                "Id": "123",
                "AccountEnabled": true,
                "BusinessPhones": [],
                "Department": "abc",
                "DisplayName": "abc",
                "Mail": "abc@mail.com",
                "MailNickname": "abc",
                "UserPrincipalName": "abc@mail.com"

}
 
I tried different methods including the action 'Condition' and 'Filter Array' with the expressions but failed:
e.g. 
@not(empty(outputs('search_for_users_(V2)')?['body/businessPhones']))
@not(equals(outputs('search_for_users_(V2)')?['body/businessPhones'], null))
@not(equals(empty(outputs('search_for_users_(V2)')?['body/businessPhones']),true))
@not(equals(outputs('search_for_users_(V2)')?['body/businessPhones'])?[0], null))
 
Moreover, I would also like to display the business phones in string instead of array.
Current display in SharePoint List: ["1234 5678"] (same as the output of 'get user profile')
Idel display: 1234 5678
 
How can I solve the above problems? Many thanks.
 
  • Suggested answer
    HC-08110621-0 Profile Picture
    HC-08110621-0 6 on at
    Filter empty BusinessPhones and change BusinessPhones to string
    Thanks @alpa Mahesh Dhola . It probably because I did not put a loop before I use the empty function.
     
    Here's how I solve the problem finally. I put the actions after 'get user profile' instead of 'search for user (V2)'.
     
    1. Change BusinessPhones to string
    Add a ’Compose' action to return the first item in the BusinessPhones array.
    2. Filter empty BusinessPhones
    After 'Compose', add conditions.
  • Verified answer
    Filter empty BusinessPhones and change BusinessPhones to string
    1. You need to change the condition as 
         
           Apply to each 
           
          outputs('search_for_users_(V2)')?['body/value']

          after that, add the condition action with expression
     
        not(empty(item()?['BusinessPhones']))
     
    2. And to get a string from BusinessPhones array, you will have to iterate the BusinessPhones array and append to one string variable and then directly add that variable to SharePoint list field

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

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,591

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,090

Leaderboard