cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Kadd
Resolver III
Resolver III

how to check if SharePoint list exists

Hi everyone,

I'm using Power Automate and I'm trying to check if a sharepoint list exists on my sharepoint online site.

I managed to do this for Sharepoint groups using an HTTP request. so i did the same in this case but it doesn't seem to be working.

 

2021-02-25 13_35_09-Inbox - cedric.jacquemin@nexusit.online - Outlook.png


I create a variable that is an array, question the site, get the result and then depending on the fact that the array is empty or not, it goes in my condition.

 

the thing is if i set the variable as an array, it stops at my "Set Variable" and tells me the variable is an array and can't be initialized with a string.

 

if i set the variable as a string, it goes to the condition and doesn't seem to figure out that the length of my variable is ... 0 ... so it goes on the NO side and crashes because the list doesn't exist.

 

would anyone be able to help me on this ?

thanks a lot and regards

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Kadd 

 

That's not a valid expression as you are missing the ? for a start.  You've put:

body('Send_an_HTTP_request_to_SharePoint_-_Check_list_exists')['d']['results']

 

Please try:

outputs('Send_an_HTTP_request_to_SharePoint_-_Check_list_exists')?['body']?['d']?['results']

View solution in original post

9 REPLIES 9
DamoBird365
Super User
Super User

@Kadd have you tried setting the variable type to object?

Kadd
Resolver III
Resolver III

Hi @DamoBird365 ,

 

yes, and error is the same " the variable varResult of type Object cannot be initialized or updated with value of type string. The variable only supports values of type Object"

 

 

Can you share the output from the history of the SharePoint HTTP request?

DamoBird365
Super User
Super User

@Kadd ,

 

I think you need to check your expression for the set variable - try:

 

outputs('Send_an_HTTP_request_to_SharePoint')?['body']?['d']?['results']

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien


P.S. take a look at my new blog here

Kadd
Resolver III
Resolver III

@DamoBird365 , yes...

 

PXL_20210225_181244715~2.jpg

Kadd
Resolver III
Resolver III

@DamoBird365 ,

 

in my Set variable i have 

 

body('Send_an_HTTP_request_to_SharePoint_-_Check_list_exists')['d']['results']

 

That's what i also did when checking if SP Groups exist in another workflow and this worked.

Hi @Kadd 

 

That's not a valid expression as you are missing the ? for a start.  You've put:

body('Send_an_HTTP_request_to_SharePoint_-_Check_list_exists')['d']['results']

 

Please try:

outputs('Send_an_HTTP_request_to_SharePoint_-_Check_list_exists')?['body']?['d']?['results']

Kadd
Resolver III
Resolver III

Hi @DamoBird365 ,

 

ok so i added "outputs...."  and now it seems to be good. I had to initilize the varResult as an array.

I still have a problem because between yesterday and today...my flow doesn't restart anymore but i did so many changes that it might come from this.

 

Anyway, now, this part seems to be good, i have to check the rest.

 

Thanks a lot for your help !!!

AishwaryaB1
New Member

Hi,

 

Please use empty() function to check the object is null or not. For me it worked.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

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

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Users online (1,960)