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 / Get user profile v2 - ...
Power Automate
Answered

Get user profile v2 - After user Not Found solved, error when trying to use "Append to array variable"

(0) ShareShare
ReportReport
Posted on by 6

Hi, 

 

Using 'get user profile v2' I am basically getting the name for users id assigned to tasks in planner. However, there are multiple users so I need to append them to a single variable. Now, because some users have left the organization, I had to ask it to also bring failures - it then populates the variable with null. When I try to append to arra,  I get the following error: BadRequest. The value cannot be null. The action type 'AppendToArrayVariable' only supports values of types 'Float, Integer, String, Boolean, Object'.

 

1) Get user profile (V2)

 

MarceloBastos_0-1714574020963.png

2) 

MarceloBastos_1-1714574191112.png

 

MarceloBastos_2-1714574204335.png

Any ideas on how to handle it?

Categories:
I have the same question (0)
  • David_MA Profile Picture
    12,978 Super User 2025 Season 2 on at

    Based on your screen shots, it is a little difficult to tell what you're doing because I don't see how the user profile action would return an array for the apply to each. However, you don't want to have the append to action run if the Get user profile action fails. 

     

    This isn't exactly the same as your process, but it will show what to do when the get user profile action fails and you want the flow to continue.

    David_MA_0-1714581809042.png

    After your Get user profile action, you want to add a parallel branch. On the left side you will put your actions to append your array variable. The first action on this side will be set to only run when the action above (Get user profile) is successful, which is the default. On the right side you will put actions for when the Get user profile fails. In your case, I would say to do nothing, and just add a Compose action and put 'User Not Found' in the body of the Compose action Then set this action to only run when the Get user profile action fails.

    David_MA_1-1714582004530.png

     

  • MarceloBastos Profile Picture
    6 on at

    I am sharing below the steps before and after with more information. Do you think it helps to give you extra context?

    A simple way to solve the problem is that, if it Get use profile fails, then, it should populate with a string "NoLongerAUser". But I don't know how to do it. 

     

    MarceloBastos_0-1714641588323.png

     

    Compose:

    xpath(xml(json(concat('{"body":{"value":', body('List_tasks')?['value'] , '}}'))), '/body/value/_assignments/userId/text()')

     

    Compose 2:

    union(outputs('Compose'),outputs('Compose'))

     

    Initialize variable:

    MarceloBastos_1-1714641588324.png

     

    MarceloBastos_2-1714641588325.png

     

    Compose 4:

    addProperty(variables('var_mappingTable'),item(),outputs('Get_user_profile_(V2)')?['body/displayName'])

     

    Set variable 2:

    MarceloBastos_3-1714641588325.png

     

    MarceloBastos_4-1714641588327.png

     

    Apply to each:

    Planner value

     

    Select:

    MarceloBastos_5-1714641588327.png

     

    Apply to each 4:

    MarceloBastos_6-1714641588328.png

     

    Append to array variable:

    MarceloBastos_7-1714641588329.png

     

    variables('var_mappingTable')?[item()]

     

  • Verified answer
    David_MA Profile Picture
    12,978 Super User 2025 Season 2 on at

    You can do what I mentioned before with regard to the parallel branch after the Get user profile action. Here are the steps again hopefully written more clearly.

    1. Get User Profile Action:
      • Start with your existing “Get user profile” action.
      • This action retrieves user information from Active Directory (AD).
    2. Parallel Branch:
      • Add a parallel branch after the “Get user profile” action.
      • The parallel branch allows you to handle different scenarios simultaneously.
    3. Left Side (Success Path):
      • On the left side of the parallel branch, add actions to append data to your array variable (if needed).
      • The first action on this side should be set to run only when the “Get user profile” action is successful (which is the default behavior).
      • This means that if the user profile is found in AD, the actions on the left side will execute.
    4. Right Side (Failure Path - User Not Found):
      • On the right side of the parallel branch, add actions to handle the case when the “Get user profile” action fails (i.e., the user is not found in AD).
      • In your case, you can simply add a “Compose” action.
      • Set the body of the “Compose” action to the text “User Not Found.”
      • Configure this action to run only when the “Get user profile” action fails.
  • MarceloBastos Profile Picture
    6 on at

    Hi David,

    I run into other errors.

    Please check my steps:

    MarceloBastos_0-1715776812500.png

     

     

    For compose 1 (Error path) I added the formula:

    if(equals(outputs('Get_user_profile_(V2)'), null), 'NonExistentUser', string(outputs('Get_user_profile_(V2)')))

     

    For apply each, the error:

     

    Append to array variable [Error: 

     
    BadRequest
    The value cannot be null. The action type 'AppendToArrayVariable' only supports values of types 'Float, Integer, String, Boolean, Object'.]

     

     

  • David_MA Profile Picture
    12,978 Super User 2025 Season 2 on at

    Try this expression instead: 

    if(empty(outputs('Get_user_profile_(V2)'), 'NonExistentUser', string(outputs('Get_user_profile_(V2)')))

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
Michael E. Gernaey Profile Picture

Michael E. Gernaey 503 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 321 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard