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
Microsoft
Microsoft

@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
Microsoft
Microsoft

@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 Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (2,940)