cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
RobDin
Frequent Visitor

OnVisible Incomplete Collection : Doesn't Populate with User Check

When my app opens I'm trying to check to see if the user has used the app before. In my data source I've created a table called 'Users' with a couple attributes. When I run a ClearCollect for that table in OnVisible, the collection populates just fine. When I add the following code that checks the collection for the current user the collection is incomplete.

 

ClearCollect(XUsers,'[dbo].[Users]');
If(User().FullName <> LookUp(XUsers,UserName = User().FullName,UserName), Patch('[dbo].[Users]',{GUID: Text(GUID()), UserName: User().FullName, DateAdded: Now(), Administrator: 0, LastLogin: Now()}
));

 

 

If I check the collection I only see two data fields getting filled. (See attachment)

1 ACCEPTED SOLUTION

Accepted Solutions
RobDin
Frequent Visitor

I found a solution to this. If I only add the UserName field (the only field I'm checking against) to my XUsers collection it works every time. 

ClearCollect(XUsers,Distinct('[dbo].[Users]',UserName));

 

I used Distinct to avoid the possibility of a duplicate during testing.

View solution in original post

4 REPLIES 4
ZabiBabar
Continued Contributor
Continued Contributor

Try this instead:

ClearCollect(XUsers,'[dbo].[Users]'); Set(currentUserName, User().FullName);
If(IsEmpty(LookUp(XUsers, UserName = currentUserName)), Patch('[dbo].[Users]',{GUID: Text(GUID()), UserName: currentUserName, DateAdded: Now(), Administrator: 0, LastLogin: Now()}
));

 

timl
Super User III
Super User III

Hi @RobDin 

The most likely cause of this is that you have the 'explicit column selection' setting enabled. Can you try disabling this if you have it set?

 

image.png

 

RobDin
Frequent Visitor

Thank you for the suggestions. I tried both and it didn't remedy the problem. 

As an experiment I removed the whole If statement from OnVisible and the collection had the same issue. So I'm thinking my ClearCollect is having a problem getting data from my Azure SQL Server database.

RobDin
Frequent Visitor

I found a solution to this. If I only add the UserName field (the only field I'm checking against) to my XUsers collection it works every time. 

ClearCollect(XUsers,Distinct('[dbo].[Users]',UserName));

 

I used Distinct to avoid the possibility of a duplicate during testing.

View solution in original post

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (84,767)