cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper III
Helper III

Checking if Record Exists

Hi all,

I will try to explain this as best as I can so it isn't too confusing. I'm trying to design an app that's using records/creating records in multiple sharepoint lists. I have looked up information on how to create relationships between my table but it seems I need to add the relationship entity, which I am blocked from doing by the Admin. Failing that I was going to try and use variables. Not as good I know but I am not sure what to do to work around it, and I am very new to PowerApps. I don't think I will be given the rights to add the relationship entity. Just a note the relationships would always be one to one (one project ID will only ever have one record on each table I mention below) related by the ProjectID.

 

I have the following sharepoint lists: Projects, SectionSelect, Section 1, Section 2.

 

On Screen1 I have a gallery of the Projects data source. I have a button that when selected it sets a variable of the ProjectID and Navigates to Screen2 which has a form with SectionSelect data source on it. This works fine, however, what I'm trying to do is if there is already a record in SectionSelect for this project ID, that it instead goes to Screen3, which will have multiple forms on it for Section 1 and Section 2 data sources.

 

If my button on Screen 1 is just setting the Variable and Navigating to Screen 2 it works fine, but when I try to add the IF statement into it, it all goes wrong, it's not recognizing the variable in the IF, presumable because it's all happening within the one statement? Maybe I'm just not putting things in the correct order or writing them properly.

 

Can anyone tell me if there is another way around relationships? If this will work and if so maybe how to write that code for that button?


Thank you in advance for your time and thoughts.

13 REPLIES 13
Highlighted

@Nunzie please re-post your code you are using on the button. Could you also share the OnVisible code (if any) of your two other screens.

Highlighted

Hi, Not sure what was going on but, I removed the column ProjectID in the SSD section Table, re-added it but renamed it ModusID, then updated the code and it worked. It is now swapping screens. However I still get the delegation warning. This is my updated code.

 

Set(vProjectID,ThisItem.'Project ID'); If(CountRows(Filter('Test - SSD Sections',ModusID = ThisItem.'Project ID'))=0, Navigate(SSDSectionPick,ScreenTransition.Fade),Navigate(SSD, ScreenTransition.Fade))

 

Both the SSD SectionPick screen and SSD screen are blank in the On Visible as I hadn't attempted to figure out how to show the related data since I was having trouble with the above code. So obviously then it isn't showing data from the two tables on those layouts not knowing what to show.

Highlighted

@Nunzie 

I think this should sort your delegation issue

Set(vProjectID,ThisItem.'Project ID'); 

If( IsBlank( 
       First( 
           Filter('Test - SSD Sections',ModusID = ThisItem.'Project ID')
       )
     ), 
     Navigate(SSDSectionPick,ScreenTransition.Fade),
     Navigate(SSD, ScreenTransition.Fade)
)

 

Hope this helps.

 

View solution in original post

Highlighted

That did it! Thank you!

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (8,634)