cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dave8
Impactful Individual
Impactful Individual

How to display error message if value already exist?

Hello,

 

I have a CDS Entity having Primary Name Field called "Item ID" which is bound with Edit Form control.

 

I want to display an error message, if duplicate field is found already in the entity.

 

which formula I can use to identify whether value is unique or not?

 

Thanks,

2 REPLIES 2
eka24
Super User III
Super User III

Follow this Post;

https://powerusers.microsoft.com/t5/Building-Power-Apps/Check-if-record-exist/td-p/377121

 

If you have issues give a feedback of your code

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

FilipeRelvas
Microsoft
Microsoft

Hello Dave,

 

Please correct me if I'm wrong but if I understood you correctly you want to display a message when you submit the form stating the Field in question is duplicated and prevent a record create / update from happening, correct?

 

I believe you have two distinct options here:

 

Server Side:

Since these records will be kept in a CDS / Dynamics environment you can create an Alternate Key which will throw an error based on the Field of your choice if it detects a duplicate. The CDS connector while making the submission to the Datasource will then show a similar error to this one:
FilipeRelvas_2-1600692513848.png

 

Documentation:

https://docs.microsoft.com/en-us/powerapps/maker/common-data-service/define-alternate-keys-portal

 

Note:

Please note that if you already have duplicates in the system, make sure you resolve them before creating the Alternate Key otherwise it won't work as the System Job that will create will fail.

 

 

Client Side:

You can also perform a check before submitting the form by performing a request against the Data Source and looking for any records with that same Field Value. You can use the Lookup() function to do so.

 

Example: 

LookUp(Accounts, 'Account Name' = DataCardValue.Text) --> This will return the first record that meets the condition. Which means that if a record is returned a duplicate exists and you should Notify the user and abort or prevent the form submission.

 

Hope this helps 🙂

 

Filipe Relvas.

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

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (30,644)