cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Get user profile (V2) - checking if user exists in Office365 from Excel list

Hi there,

 

I read almost all of the "Get user profile (V2)" questions, but couldn't find an answer to this one exactly.

I'm trying to read an email from Excel and checking if an email exists in O365.

What I want to achieve is if email from Excel exists -> send an email

If email from Excel not exists -> log "bad email entry" to Excel

 

It is easy as long as email exists, but when an email does not exists, this is error what I get and I cannot extrapolate bad request and log bad email back to excel into a column.

 

Please take a look at the screenshots below.

I'm checking if "Employee EMAIL" exists, if so -> put it in the "Correct Email" column, otherwise in the "Incorrect Email"

 

Bad request output

{"statusCode":404,"headers":{"Transfer-Encoding":"chunked","Vary":"Accept-Encoding","Strict-Transport-Security":"max-age=31536000","request-id":"fdc19193-f001-43e3-bb17-fa208e6efbae","client-request-id":"fdc19193-f001-43e3-bb17-fa208e6efbae","x-ms-ags-diagnostic":"{\"ServerInfo\":{\"DataCenter\":\"West Europe\",\"Slice\":\"E\",\"Ring\":\"5\",\"ScaleUnit\":\"002\",\"RoleInstance\":\"AM2PEPF00005DCA\"}}","Timing-Allow-Origin":"*","x-ms-apihub-cached-response":"true","Date":"Mon, 12 Apr 2021 07:36:42 GMT","Content-Type":"application/json","Content-Length":"284"},"body":{"error":{"code":"ResourceNotFound","message":"User not found","innerError":{"date":"2021-04-12T07:36:43","request-id":"fdc19193-f001-43e3-bb17-fa208e6efbae","client-request-id":"fdc19193-f001-43e3-bb17-fa208e6efbae"}}}}

 

1.PNG2.PNG

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Anonymous 

Sorry, I made a mistake and the correct expression in the condition should be:

length(outputs('search_for_users_v2))

And in the compose action would be:

first(outputs('search_for_users_v2))?['email']

Hope it helps!
Ferran

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!

View solution in original post

5 REPLIES 5
fchopo
Super User
Super User

Hi @Anonymous 

You could capture if there's an error in the "get user profile" action and send it to Excel:

 

runafter.png

 

failed.png

 

In this way, the "add row into a table Excel" action will be executed only if there's an error in the "Get user profile" action.

Hope it helps!

Ferran

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!
Anonymous
Not applicable

Hi @fchopo

 

I did as you explained and it's a partial solution.

What happens is next -> it fills in excel sheet with the results, but gives me a run fail status anyways - because it is either waiting for (success or fail) status.

I think there should be a control in place before, but don't know how to do it with the output of the Get User Profile Output.

 

 

a1.PNGa2.PNGaa.PNGaaa.PNG

fchopo
Super User
Super User

If you want to avoid this, I would recommend you change the flow, and instead of using "Get user profile", call "Search for users":

existinguser.png

 

1) Search for the user

2) If number of items is greater than 0

  2.1) Get the first user's found email

  2.2.) Add row into Excel

3) If not exists -> Add another row into Excel

 

Hope it helps!

Ferran

 

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!
Anonymous
Not applicable

@fchopo 


For some reason this is still not working

I have tried with one correct email, and with another incorrect using your suggestion with len, but no success.

 

ff1.PNGff2.PNG

Hi @Anonymous 

Sorry, I made a mistake and the correct expression in the condition should be:

length(outputs('search_for_users_v2))

And in the compose action would be:

first(outputs('search_for_users_v2))?['email']

Hope it helps!
Ferran

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!

Helpful resources

Announcements
 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Users online (1,350)