cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
anubhav29
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
v-yutliu-msft
Community Support
Community Support

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

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
GerbenB
Frequent Visitor

Hi there, please try this snippit

 

 

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

 

 

 

v-yutliu-msft
Community Support
Community Support

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

EricRegnier
Super User II
Super User II

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

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

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

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Kudoed Authors
Users online (61,028)