cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jja
Post Prodigy
Post Prodigy

Check if related record exists in another table

Hi

I have 2 main tables in a dataverse. In table Components table I store my equipment. In table Transactions i register what was done with that equipment. 

I have a custom page model driven app where i select a Project name and it lists me in a gallery all equipment that is associated with this Project. Then i select with check boxes gallery items and select a certain task to be done for that equipment lets say Painting.

When i hit Submit button it patches a records of selected gallery items in Transactions table and also patches this specific task as Painting for each record. 

I want to make some security so that user does not register same item twice for same task. For example if user selects some items in a gallery and selects task to be registered(or vice versa) the gallery checkbox is unselected and disabled or gallery items changes color to red or gallery items just do not load if record already exist. Anything would help for beginning

Can you please suggest how to do that?

7 REPLIES 7
Nogueira1306
Super User
Super User

Why don't you do a LookUp?

Imagine that the field that stays the same and sets the connection is the id.

 

You can do something like:

If( IsEmpty(LookUp(DataSource, TaskID = ThisItem.TaskID)), PATCH, Notify("Task already submitted"))

 

Something like that 

 

If you need additional help please tag me in your reply and please like my reply.
If my reply provided you with a solution, pleased mark it as a solution ✔️!

Best regards,
Gonçalo Nogueira

Check my LinkedIn!

Check my User Group (pt-PT)!

Last Post on Community

My website!

jja
Post Prodigy
Post Prodigy

Hi @Nogueira1306 

OK. I want to check if it works so i created a label in gallery and put formula for simple checking

If(IsEmpty(LookUp(transactions,'equipment lookup'=ThisItem.name)),"Not present","Present")

But i get error: incompatable types of comparison. These types can't be compared: Record, Guid

'equipment lookup' is a lookup field name in trasnactions table and name is a name of that equipment in equipment table

If(IsEmpty(LookUp(transactions,'equipment lookup'.name=ThisItem.name)),"Not present","Present")


And like that?

hi @Nogueira1306 

it returns that all  are present thow i have entered only 1 item into transactions table

If LookUp is empty it should say that it is not present because you did not find anythin.g So, try this:

 

If(IsEmpty(LookUp(transactions,'equipment lookup'.name=ThisItem.name)),"present","Not Present")

 

If you need additional help please tag me in your reply and please like my reply.
If my reply provided you with a solution, pleased mark it as a solution ✔️!

Best regards,
Gonçalo Nogueira

Check my LinkedIn!

Check my User Group (pt-PT)!

Last Post on Community

My website!

it says now not present for both records thow 1 record should be marked as present

Are you sure that the lookup is correct? 

You can try with IsBlank instead of IsEmpty

 

If you need additional help please tag me in your reply and please like my reply.
If my reply provided you with a solution, pleased mark it as a solution ✔️!

Best regards,
Gonçalo Nogueira

Check my LinkedIn!

Check my User Group (pt-PT)!

Last Post on Community

My website! 

Helpful resources

Announcements
Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Government Carousel

New forum: GCC, GCCH, DoD - Federal App Makers (FAM)

In response to the unique and evolving requirements of the United States public sector, Microsoft has created Power Apps US Government.

Users online (4,778)