web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Unique Field when subm...
Power Apps
Unanswered

Unique Field when submitting form

(0) ShareShare
ReportReport
Posted on by 50

Hi,
I have a form which looks like this:

AlvinCassar_0-1680789082331.png

 

When creating a new event or editing an existing one, I need to make sure that the Event Name is unique from any others.
On the submit key, 

AlvinCassar_1-1680789176150.png

 

I have this code, which works perfectly when adding a new event, and blocks the user from adding the user the same event name.

This also works perfectly if a user wants to change a current Event Name to another name which an Event already has.

 

But, this does not work when clicking edit, changing the description for example and trying to resubmit the form with the old Event Name as this name would have already been found in the table as an Event Name.

 

 

If(CountIf(Events, 'Event Name' = varEventName.Value) < 1,
 SubmitForm(EditForm1),
 Notify("Event Name cannot be used as it already Exists.", NotificationType.Error)); 

 

 

Thank you for your help.

Categories:
I have the same question (0)
  • BCBuizer Profile Picture
    22,844 Super User 2026 Season 2 on at

    Hi @AlvinCassar ,

     

    The below formula is meant to check if the eventname already exists and if it is, if it's the event name of the item currently selected in Gallery1 (you will have to change this name to the name of your gallery): 

     

    With({
    	_Temp: LookUp(Events, 'Event Name' = varEventName.Value)
    	},
    	If(
    		IsBlank(_Temp) || _Temp.ID = Gallery1.Selected.ID,
    		SubmitForm(EditForm1),
    	 Notify("Event Name cannot be used as it already Exists.", NotificationType.Error)
    	)
    ); 

     

    Basically this excludes the currently edited record from the rule.

  • AlvinCassar Profile Picture
    50 on at

    Hi @BCBuizer,

     

    Thanks for your response and this works for when editing an existing event, but when adding a new event, it does not care for others and will add no matter what the name is.   

  • BCBuizer Profile Picture
    22,844 Super User 2026 Season 2 on at

    Hi @AlvinCassar ,

     

    Can you please provide an example and share which of the two conditions is returning a true? 

  • AlvinCassar Profile Picture
    50 on at

    Hi @BCBuizer,

    Sorry for the late reply, basically the problem occurs when;

    If an event is called "Testing 4" I can add a new event called "Testing 4". (which is incorrect)


    But, when an event is called "Testing 4" and I want to change it to "Testing 3" while another event is called "Testing 3" this does not let me change it. (which works how it is intended to)

     

    Basically this is my code, 

     

    With(
     {
     _Temp: LookUp(
     Events,
     'Event Name' = varEventName.Value
     )
     },
     If(
     IsBlank(_Temp) || _Temp.'Event Name' = BrowseGallery1.Selected.'Event Name',
     SubmitForm(EditForm1),
     Notify(
     "Event Name cannot be used as it already Exists.",
     NotificationType.Error
     )
     )
    );
  • BCBuizer Profile Picture
    22,844 Super User 2026 Season 2 on at

    Hi @AlvinCassar ,

     

    How is varEventName populated? Perhaps this should be replaced with at reference to the DataCardValue that has the Title:

     

    With({
    	_Temp: LookUp(Events, 'Event Name' = DataCardValue1.Text)
    	},
    	If(
    		IsBlank(_Temp) || _Temp.ID = BrowseGallery1.Selected.ID,
    		SubmitForm(EditForm1),
    	 Notify("Event Name cannot be used as it already Exists.", NotificationType.Error)
    	)
    ); 
  • AlvinCassar Profile Picture
    50 on at

    AlvinCassar_0-1682515442592.png

     

  • BCBuizer Profile Picture
    22,844 Super User 2026 Season 2 on at

    Hi @AlvinCassar ,

     

    Did you try the formula I shared in my previous post? It seems I accidentally chose the correct name for the DataCardValue, so it should work as it is.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 329 Most Valuable Professional

#2
11manish Profile Picture

11manish 209 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 179

Last 30 days Overall leaderboard