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

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 Partisan
Post Partisan

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 Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (2,974)