cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jms345
Regular Visitor

Button to Notify if a field is matched in a sharepoint list

I am using PowerApps connected to a Sharepoint List "Contacts", with a field called Full Name.

I have a form which is opened in NEW mode to accept a new contact. I concatenate (First Name, " ",Last Name) in a label called CheckFullName, and have a button called CHECK which does the following:

If(IsBlank(LookUp(Contacts.'Full Name' = Checkfullname)),Notify("Name exists",NotificationType.Warning))

This shows errors:  Incompatible Types for Comparison..Button3.Onselect

                               

Full Name is a String; I tried using CheckFullname.Text but still get incompatible types.  Also do not understand Invalid no. of arguments.

I removed the NOTIFY command and replaced with changing a Text box (Label) message to visible, but this didn't work - so then just tried to make the button change the label to visible, but it still didn't work.  Can you not change the properties in a form in NEW mode?  Sorry if this is more than one question!!

1 ACCEPTED SOLUTION

Accepted Solutions

@jms345 ,

Firstly, the record in the form should be the one selected if what you posted is correct - you can try this - Gallery OnSelect

Set(
   gblID,
   ThisItem.ID
);
ViewForm(EditForm1);
Navigate(
   ClientDetails,
   ScreenTransition.CoverRight
)

The Item of the Form

LookUp(
   Contacts,
   ID = gblID
)

For a new record, all you need is

NewForm(EditForm1);
Navigate(
   ClientDetails,
   ScreenTransition.CoverRight
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

 

View solution in original post

12 REPLIES 12
WarrenBelz
Super User
Super User

Hi @jms345 ,

You were close

If(
   !IsBlank(
      LookUp(
         Contacts,
         'Full Name' = Checkfullname
      ).'Full Name'
   ),
   Notify(
      "Name exists",
      NotificationType.Warning
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

Many thanks, but I am still getting an error (different though!)

Unexpected characters. The formula contains 'ParenClose' where 'Eof' is expected. This error occurs if, for example, a formula contains 'This error occurs if, for example, a formula contains '{Val@ 7}' instead of '{Val: 7}'.

I also tried adding a notify if the new record is OK, but there is no notification:

If(
!IsBlank(
LookUp(
Contacts,
'Full Name' = Checkfullname
).'Full Name'
),
Notify(
"Name exists",
NotificationType.Warning
),Notify(
"OK",
NotificationType.Success
)

 

jms345
Regular Visitor

Would it be possible instead of notifying a message, to display 2 or 3 fields of any matching records in a separate table?  E.g. IF MATCH DISPLAY FULL NAME, DoB, ID , ALLOW USER TO SELECT AND EDIT EXISTING RECORD

                  ELSE DO NOTHING

@jms345 ,

Firstly you are missing a closing bracket of the code you posted

If(
   !IsBlank(
      LookUp(
         Contacts,
         'Full Name' = Checkfullname
      ).'Full Name'
   ),
   Notify(
      "Name exists",
      NotificationType.Warning
   ),
   Notify(
      "OK",
      NotificationType.Success
   )
)

In answer to your second question, yes, but could be a bit complex depending on your Power Apps experience. You would need a pop-up (a gallery in this case) with the visible set to a variable which would be set to true instead of showing the warning. The Items would be

Filter(
   Contacts,
   'Full Name' = Checkfullname
)

and then either make it editable, or have a form pop-up as well based on the selected item in the gallery.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

Thanks again for your help.  The code doesn't show an error if I replace my label with a name in quotation marks (i.e. replace CheckFullName with "Joe Bloggs" and it runs - but no matter what value I type it always notifies "OK"

Does that mean that simply calling the label CheckFullName doesn't turn it into a variable that can be used in a condition?  I tried Set(CheckName=CheckFullName) but I still get an error in the condition (under "=")

As you can see I am a beginner but have some VB experience

jms345
Regular Visitor

I checked that the variable CheckName is set by navigating to a new screen and applying it to the Text property of a label - it correctly shows the name.  However in the Lookup code, the = sign still shows an error.  Confused!

jms345
Regular Visitor

I changed the = to "in", then "exactin" and the error disappeared, however the search still showed the same notification message whether a name existed in contacts or not.  I have decided to tackle this in a different manner. I hvae a new screen with a gallery and a textinput.  The filter on the gallery item is the textinput checking the full name - as you type it filters down the contacts so you can see if the name exists.  I am now adding a button to create a new record if the name does not appear.

jms345
Regular Visitor

OK so I now have a problem matching the edit record from the gallery.  The gallery correctly filters the records so you can see names that match the textinputbox. When I click the Nextarrow in the datacard, it does not move to the correct record.  The code I use is:  ViewForm(EditForm1); Navigate(ClientDetails,None) - where EditForm1 is linked to the Contacts list, showing textboxes for each field and ClientDetails is the Screen which contains EditForm1.  How do I make this form open with the record I select in the gallery?

@jms345 ,

I am struggling a little to absorb all of that - I am assuming you now have a gallery and a form connected to the record selected in the gallery. What are the Items of the gallery and the DataSource and Item of the Form (in Text please)

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.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (3,235)