Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
I have a PowerQuery that has to iterate throught 1,000+ SharePoint sites, and pull some data from a specific list on each site. Now obviously each site, having it's own configuration means there's lots of room for mistakes.
There are four possible outcomes which I am trying to identify:
So here's what my table of URLs looks like:
Col1 | Col2 | SiteURL |
... | ... | https://.....sharepoint.com/sites/exmlex/ThisIsSite2/Forecast |
... | ... | https://.....sharepoint.com/sites/exmlex2/ThisIsSite3/Forecast |
... | ... | https://.....sharepoint.com/sites/exmlex/ThisIsSite67/Forecast |
... | ... | https://.....sharepoint.com/sites/exmlex/ThisIsSite5/Forecast |
Coincidentially it's some of the exmlex2 sites that are the culprits - but there is no predicting whch one will give problems.
So each site has a list, with a specific name, and that is the list I want to check.
The list name is "Forecast", obviously on each site each site, the list will have a different GUID, so it has to be done by name.
What I am trying to achieve is this:
Col1 | Col2 | SiteURL | Result |
... | ... | https://.....sharepoint.com/sites/exmlex/ThisIsSite2/Forecast | LastModified |
... | ... | https://.....sharepoint.com/sites/exmlex2/ThisIsSite3/Forecast | No list exists |
... | ... | https://.....sharepoint.com/sites/exmlex/ThisIsSite67/Forecast | Access Denied |
... | ... | https://.....sharepoint.com/sites/exmlex/ThisIsSite5/Forecast | Not used |
... | ... | ... | ... |
So... I need a table of URLs, and a custom function with some error handling. The process must complete, despite all obstacles.
My biggest problem, is that I cannot make error handling work in a custom function, when the error is the datasource.
let
Source = ...,
....
#"Added Custom" = Table.AddColumn(#"Source", "Forecast", each
try
interrogateList([siteURL])
otherwise
"Something else unforseen"
),
in
#"Added Custom"
And here is the custom fuction interrogateList()
let
Source = (URL as any) =>
let
Source2 = try
SharePoint.Tables(URL, [ApiVersion = 15])
# if not empty, try get the last modified date
otherwise
"Access Denied"
in
#"Source2"
in
Source
The script runs fine but a "problem url" does not get trapped - it just bombs with "The credentials provided are invalid" - so this error handling is ineffective.
Another perspective: It's not an HTTP error - SharePoint is serving up the response just fine.
It's an authentication issue.
Hi @Netrelemo,
You can create a table with a list of these source SharePoint URLs, then you can add a custom column with try/otherwise structure and data connector to invoke and catch the result of these links.
Regards,
Xiaoxin Sheng
I know. That's exactly what I am doing now. But it doesn't work.
Hi @Netrelemo,
Can you please share some more detail about your sceniaro? They should help us clarify your scenario and test to coding formula.
How to Get Your Question Answered Quickly
Regards,
Xiaoxin Sheng
I've tried to reword the problem with more detail
Check out the September 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.