cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
GauravG
Responsive Resident
Responsive Resident

Show error messages for a non-required hyperlink field

Hi All,

I have a field "BRD Supplement Link" defined as "HyperLink" in my SharePoint list.

The issue is that if it is required i see an error.

When it is optional i do not see an error message- how can i make the error message pop-up even if it is not a mandatory field.

Please see what i have at the moment at the visible property of ERROR CONTROL

GauravG_0-1611600862402.png

Also, the Parent card's required property is  dependent on a toggle field and the formula for that is - DataCardValue40_3.Value

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User III
Super User III

@GauravG 

I think I'm following...

So, change the Required property of the DataCard to:

DataCardValue40_3.Value || !IsBlank(DataCardValue45_3.Text)

 

Set the Update Property to the following:

If(!IsBlank(DataCardValue45_3.Text) && !("https://***BRD***" in DataCardValue45_3.Text) && Parent.Required, Blank(), DataCardValue45_3.Text)

 

Let's see if that hits the mark!

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

11 REPLIES 11
RandyHayes
Super User III
Super User III

@GauravG 

If you want that to appear in all cases, then you can just take the !Parent.Valid out of the formula.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!
GauravG
Responsive Resident
Responsive Resident

@RandyHayes I thought so too- unfortunately that did not work.

Now my formula looks like 

GauravG_0-1611606567442.png

And now, if i try to put any random value (not link) in the hyperlink field- it lets me input it and save the form- but doesn't show the value in data source. It did not even show the error or stop me from saving the form if it doesn't consider it as a hyperlink. It just lets me save, discards my inputted value and i see a blank. See Gif below

Link field Stays Blank-min.gif

RandyHayes
Super User III
Super User III

@GauravG 

Yes...If I recall correctly, we put the formula in the Update property of that datacard to trick the validation.  If the entry did not contain "//" in it, I believe it is setting to Blank.  This is what caused the Valid property to become false because it was required (based on the toggle).

SO, if you want to store whatever is in the entry, then change the Update property and remove the logic to "invalidate" the datacard.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!
GauravG
Responsive Resident
Responsive Resident

@RandyHayes That's god-level memory. I forgot that Randy.

Now, we want the file link to be coming from a particular library within our SP and hence this formula in UPDATE property

GauravG_0-1611611371168.png

I want to retain this logic, how do i invalidate the field to show the error message whenever somebody is putting any other link that does not contain this?

RandyHayes
Super User III
Super User III

@GauravG 

I believe you want to validate only if it needs to be validated, otherwise just pass through whatever is in that input.

So, change the formula in the Update to:

If( !("htt.....cedocs" in DataCardValue45_3.Text) && Parent.Required, "", DataCardValue45_3.Text)

 

That should give you the "required" logic when it is required, otherwise just save when something is not required.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!
GauravG
Responsive Resident
Responsive Resident

@RandyHayes I want to validate it without it being mandatory. Is it possible?

I know erasing the data to say blank if it does not meet our code is right too, but am afraid some users will say- we saved it- you never showed an error that it was invalid. I don't want to reason that the field wasn't mandatory and hence can't show the error. Is there a way to show irrespective if it's an error or not?

I found the way last time- but it was always showing error, i wanted it to show error only when we hit "Save"

RandyHayes
Super User III
Super User III

@GauravG 

I guess I'm a little lost on the concept though.  Consider this:

If the user enters an invalid value and it is not required (i.e. the toggle is not on) and they fill everything else out on the tabs properly and then Save...when would they ever see the error?  It would consider the value not required and would just pass the value entered in.

So, that is based on the concept that you only wanted the error to show if they hit save, and again, if everything is completed otherwise, they would save and exit and never see an error.

 

Is this perhaps where you're going with this:

Always show the error message regardless of clicking save if the value entered is invalid and if it is required, make it fail there and need to be corrected before saving, otherwise save it (noting that the user will NOT be required to change the value if it is not required and will be able to save an invalid value). 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!
GauravG
Responsive Resident
Responsive Resident

Please excuse if i have confused you- i'll try briefing again:-

 

I prefer to show the error on this non-required field only when i hit save.

 

I managed to bring up the error without requiring user to hit save but that's not a consistent experience for user. I would want to show only when i hit save and not when he is midway filling the form. This is because all others show error only when a form is being saved and it fails. I know that is because they are mandatory fields and this one is not... is there a ways to pop-up the error on non-required field only on SAVE button's failure?

RandyHayes
Super User III
Super User III

@GauravG 

So again, the issue is that if they hit Save and it is not mandatory and all the rest of the form is complete, then there will be no failure from a validation standpoint and thus it will save.

 

I could only think that you would need to introduce lclOneShot into the required property as well as the toggle check.  That would make the datacard always required until save is hit (this will allow the form to be Valid or not).

Then you could essentially make the form invalid if the value is incorrect.  Then, based on the lclOneShot determine if you can actually save it.

 

So (and apologies that I don't recall all the control names properly) in the Required property of the datacard:

   ToggleControl.Value || !lclOneShot

and in the Update property:

   If( !("htt.....cedocs" in DataCardValue45_3.Text) && (Parent.Required || !lclOneShot), "", DataCardValue45_3.Text)

This would cause the Update property to be blank if it does not meet the in operator and if it is required or not oneshotted.  So, here are the scenarios:

 

Scenario Valid Text Toggle lclOneShot Required Result
Save never pressed True True False True Nothing Shown
Save Pressed True True True True Form Saved (nothing shown)
Save never pressed True False False True Nothing Shown
Save Pressed True False True False Form Saved (nothing shown)
Save Never Pressed False True False True Nothing Shown
Save Pressed False True True True Error Shown, Nothing Saved
Save Pressed Again False True True True Error Shown, Nothing Saved
Save Never Pressed False False False True Nothing Shown
Save Pressed False False True False Error Shown, Nothing Saved
Save Pressed Again False False True False Form Saved

The last one in Red is the one you are looking for.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

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

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

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