cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PowerEmployee7
Regular Visitor

Help with BusinessPhone array

I am trying to copy data from a Microsoft Form into a sharepoint list. I am copying the "businessPhone" attribute from Office 365. It comes in as an array so I used the expression "outputs('Get_user_profile_(V2)')?['body/businessPhones'][0]" which removes the [" "] from the phone number since it is an array. However my problem is that if the array is blank, it returns an error saying "cannot be evaluated because array index '0' cannot be selected from an empty array.

 

I've been searching the forums and it looks like the way around this is to initialize a variable, but I cannot initialize a variable before my apply to each loop because I am using a Microsoft Form. Is there a way I can fix my expression so it returns blank if the array is empty?

flow1.PNG

Flow2.PNG

  

1 ACCEPTED SOLUTION

Accepted Solutions

I figured it out. Business Phones is an array. When there is no data in it, you get the error as described above because the array is empty and so the expression fails. To get around this, initialize an array variable at the top and compare Business Phones to the empty array. Then on one side, you can add the expression which removes the [""] and on the other side which has no data, you can just keep it blank since the expression would cause an error anyways.

View solution in original post

3 REPLIES 3
v-duann-msft
Community Support
Community Support

Hi @PowerEmployee7 

 

Thank you for your post.

 

The issue may caused by that unnecessary looping. Because the trigger 'when a response submitted' only works for one response. Thus, the 'apply to each' is redundant.

 

Please help to remove it and modify flow accordingly. I believe you won't get same error again.

 

Hope it helps.

 

Best regards,

Anna

I am getting the error because the business phone field is blank and so the array is blank which makes [""] in my sharepoint list.

I figured it out. Business Phones is an array. When there is no data in it, you get the error as described above because the array is empty and so the expression fails. To get around this, initialize an array variable at the top and compare Business Phones to the empty array. Then on one side, you can add the expression which removes the [""] and on the other side which has no data, you can just keep it blank since the expression would cause an error anyways.

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Users online (3,665)