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

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
DamoBird365
Community Champion
Community Champion

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

8 REPLIES 8
DamoBird365
Community Champion
Community Champion

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

Kadd
Resolver I
Resolver I

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"

 

 

DamoBird365
Community Champion
Community Champion

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

DamoBird365
Community Champion
Community Champion

@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 I
Resolver I

@DamoBird365 , yes...

 

PXL_20210225_181244715~2.jpg

Kadd
Resolver I
Resolver I

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

DamoBird365
Community Champion
Community Champion

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

Kadd
Resolver I
Resolver I

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

Helpful resources

Announcements
User Groups Public Preview

Join us for our User Group Public Preview!

Power Automate User Groups are coming! Make sure you’re among the first to know when user groups go live for public preview.

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Users online (74,836)