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

CDS : Check for record exist for lookup fields

I have a one entity which is Customer having customer Id as field, this Customer  Id is part of Customer Attribute having 1 : N relationship. 

Now I need to LookUp in the table whether the record with this Customer  Id exist or not. How can I achieve this.

 

Thanks in Advanced

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Community Support
Community Support

Re: CDS : Check for record exist for lookup fields

Hi @anubhav29 ,

Firstly, let me explain your issue:

1)entity1 named Customer: CustomerId(number type)

2)entity2 named CustomerAttribute: CustomerId(lookup type)

3)entity1 and entity2 has relationship of 1:N

4)you select one item of entity1, you want to check whether records in entity2 has related CustomerId

Am I right? If I have any mistake, please correct me.

If my assumption is right. Try this:

1)drop down1 for entity1, set drop down1's Items:

Customer

2)insert a label to represent whether there's record in entity has selected CustomerId value. True is yes, false is no.

set the label's Text:

If(
!IsEmpty(Filter(CustomerAttribute,drop down1.Selected.Name in CustomerId.Name)),
true,false
)

 

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted
Advocate II
Advocate II

Re: CDS : Check for record exist for lookup fields

You could setup a custom alternate key on the CDS entity. This should prevent duplicates from being created on the server.  On a model-driven app, the user would be presented with a somewhat jarring message alert letting them know.  On canvas, I’m not sure how that would be presented (probably as a runtime error...).

 

One thing I’ve done is setup a check in canvas apps.  I use a label hidden, and set the visibility property to a Boolean expression that is basically looking in CDS to see if a record exists that matches what the user entered in the form in the app. If there is a match, the Boolean is true and so the label’s visibility property will be set to True and the label will display to the user.  I’ve also set the submit button display mode property to be disabled if that label is showing.

View solution in original post

4 REPLIES 4
Highlighted
Frequent Visitor

Re: CDS : Check for record exist for lookup fields

Hi there, please try this snippit

 

 

IsBlankOrError(LookUp(Customers, 'Customer Id'= "1001").Name)

 

 

 

Highlighted
Community Support
Community Support

Re: CDS : Check for record exist for lookup fields

Hi @anubhav29 ,

Firstly, let me explain your issue:

1)entity1 named Customer: CustomerId(number type)

2)entity2 named CustomerAttribute: CustomerId(lookup type)

3)entity1 and entity2 has relationship of 1:N

4)you select one item of entity1, you want to check whether records in entity2 has related CustomerId

Am I right? If I have any mistake, please correct me.

If my assumption is right. Try this:

1)drop down1 for entity1, set drop down1's Items:

Customer

2)insert a label to represent whether there's record in entity has selected CustomerId value. True is yes, false is no.

set the label's Text:

If(
!IsEmpty(Filter(CustomerAttribute,drop down1.Selected.Name in CustomerId.Name)),
true,false
)

 

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted
Solution Sage
Solution Sage

Re: CDS : Check for record exist for lookup fields

Hi @anubhav29, Are you using model-driven app or canvas app? Thanks 

Highlighted
Advocate II
Advocate II

Re: CDS : Check for record exist for lookup fields

You could setup a custom alternate key on the CDS entity. This should prevent duplicates from being created on the server.  On a model-driven app, the user would be presented with a somewhat jarring message alert letting them know.  On canvas, I’m not sure how that would be presented (probably as a runtime error...).

 

One thing I’ve done is setup a check in canvas apps.  I use a label hidden, and set the visibility property to a Boolean expression that is basically looking in CDS to see if a record exists that matches what the user entered in the form in the app. If there is a match, the Boolean is true and so the label’s visibility property will be set to True and the label will display to the user.  I’ve also set the submit button display mode property to be disabled if that label is showing.

View solution in original post

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Robotic Process Automation

Let's talk about the solution provided by Microsoft for Robotic Process Automation (RPA)

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

Top Solution Authors
Users online (7,408)