cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
NigelP
Level 8

error handling of collections

HI

 

I have a PowerApp which uses SharePoint Online to store and read data.

 

I have a statement ClearCollect(collMyCollection,MyList);

 

If there is a problem with MyList eg the user does not have permissions to read MyList.

 

How do I trap this ?

 

1)  IsEmpty( Errors(collMyCollection) )

or 

2) IsEmpty( Errors( MyList ) )

 

If the list url is blocked by a firewall would I be able to trap that error and how ?

 

Thanks

 

Nigel

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: error handling of collections

@NigelP 

You could certainly check the count of the items in your collection ( CountRows(collMyCollection) ) and see if it is 0.  I'm not sure you're going to get a lot of information from the Errors collection that will point to a culprit.

However, you might want to look at the DataSourceInfo function prior to the formulas you are going to use as that will let you know the permissions that the user has to the datasource.

  DataSourceInfo(MyList, DataSourceInfo.ReadPermission) = true

if they have read access.

 

I hope that is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
5 REPLIES 5
Super User
Super User

Re: error handling of collections

@NigelP 

You could certainly check the count of the items in your collection ( CountRows(collMyCollection) ) and see if it is 0.  I'm not sure you're going to get a lot of information from the Errors collection that will point to a culprit.

However, you might want to look at the DataSourceInfo function prior to the formulas you are going to use as that will let you know the permissions that the user has to the datasource.

  DataSourceInfo(MyList, DataSourceInfo.ReadPermission) = true

if they have read access.

 

I hope that is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
NigelP
Level 8

Re: error handling of collections

Hi @RandyHayes 

Thanks for this.

Very Useful !

I had forgotten about this.

Regards

 

Nigel

 

 

Alaa-Alarori
Level: Powered On

Re: error handling of collections

Hello there,

I have a similar senario where I use collect to transfer the collection content to a sharepoint list.

After that, if the task was done successfully , I want to clear the collection but I want to be 100% sure there are no errors, otherwise, it is crucial to keep the data in the collection.

I understand one solution is to count the sharepoint list items before and after the collect function then comapre with the number of items in the collection. But CountRows is not a delegable function and might not give accurate results.

Is there any other way to handle\catch errors in the process?

 

Thanks,

Alaa

Super User
Super User

Re: error handling of collections

@Alaa-Alarori 

There are a lot of different ways to go about that issue.

 

1) Check the Errors function on each of the records you submitted.  You can remove the items from your collection as you find there are no errors.

2) Depending how you are submitting your collection items, if you are using a ForAll function, then you could collect each patch result into another collection to use to compare the two.

 

Either way, both of the above are all local.  No delegation issues with them.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Highlighted
Alaa-Alarori
Level: Powered On

Re: error handling of collections

@RandyHayes 

Thanks for your reply

Would you please add some code examples to your suggested solutions