Hi,
I am trying to validate the below code, not getting required output. Here I am validating either the user has uploaded in attachment field or has link to the attachment. But it only submits form if both are filled,
If(
CountRows(DataCardValue12.Attachments) < 1 Or IsBlank(DataCardValue2.Text),
Notify(
"File not uploaded or link to the file missing!",
NotificationType.Error,
4000
),
SubmitForm(FormNewRequest)
)
Link Field here is a hyperlink field - which is not a mandatory field.
Another issue, I am facing is that when I enter text (not a link) in hyperlink field. It doesn't submit the form, but no error is displayed. Not sure why. I checked the properties of error message text, all are valid. Strange behaviour, any idea what might be the issue.
Thanks.
Solved! Go to Solution.
Also, if you want the message only during edit, you can alter it to this:
Parent.DisplayMode=DisplayMode.Edit &&
CountRows(DataCardValue12.Attachments) = 0 &&
!IsBlank(DataCardValue2.Text) &&
IsMatch(DataCardValue2.Text, "(([\w]+:)?//)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,63}(:[\d]+)?(/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?")
Hi,
Unable to make it work, no idea what is the issue. Attaching the screenshots and codes used,
ErrorMessage2 Visible Property code
Parent.DisplayMode=DisplayMode.Edit &&
CountRows(DataCardValue12.Attachments) = 0 &&
!IsBlank(DataCardValue2.Text) &&
IsMatch(DataCardValue2.Text, "(([\w]+:)?//)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,63}(:[\d]+)?(/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?")
SubmitButton OnSelect code
Set(
varMyRequestValue,
LookUp(
MyRequest,
DLDate = Text(
DateValue2.SelectedDate,
"[$-en-GB]dd/mm/yyyy"
),
TotalSlides
)
);
If(
!IsBlank(varMyRequestValue) And varMyRequestValue < Value(DataCardValue6.Text),
Notify(
"No Availability",
NotificationType.Error,
4000
),
If(
DateValue2.SelectedDate < Today() Or Weekday(DateValue2.SelectedDate) = 1 Or Weekday(DateValue2.SelectedDate) = 7 Or DateValue2.SelectedDate > varDate Or DateTimeValue(DateValue2.SelectedDate & " " & HourValue2.Selected.Value & ":" & MinuteValue2.Selected.Value) < Now(),
Notify(
"Please select a date within 3 business days",
NotificationType.Error,
4000
),
If(
CountRows(DataCardValue12.Attachments) = 0 && (IsBlank(DataCardValue2.Text) || ErrorMessage2.Visible),
Notify(
"File not uploaded or link to the file missing!",
NotificationType.Error,
4000
),
SubmitForm(FormNewRequest)
)
)
)
Thanks
I do see that I left out a ! in my formula. I was copying and pasting from my test for you and my logic was set just a little different.
Change to:
Parent.DisplayMode=DisplayMode.Edit &&
CountRows(DataCardValue12.Attachments) = 0 &&
!IsBlank(DataCardValue2.Text) &&
!IsMatch(DataCardValue2.Text, "(([\w]+:)?//)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,63}(:[\d]+)?(/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?")
Yay... 😄 Its working finally... Thank you so much 🙂
Even I did one mistake, forgot to mention the "Link Invalid" in text property after I inserted the textbook again.
One more help, Link Invalid message is not displayed when we attach a file and also try to add a invalid link. The error message is blank and form cannot be submitted.
Thanks 🙂
So you want that to display even if there are attachments...Then change to this:
Parent.DisplayMode=DisplayMode.Edit &&
!IsBlank(DataCardValue2.Text) &&
!IsMatch(DataCardValue2.Text, "(([\w]+:)?//)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,63}(:[\d]+)?(/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?")
You can also consider setting the Visible property of the DataCard with Link in it:
CountRows(DataCardValue12.Attachments) = 0
The datacard will show if there are no attachments, but be gone if they attach.
Just a suggestion as well.
Thank you so much 🙂
Thanks for the suggestion also, I am not sure if I will be using it. B'cos sometimes user might attach and also share the link. So will retain as it is for now. 🙂
Sounds good.
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.
User | Count |
---|---|
192 | |
67 | |
46 | |
41 | |
22 |
User | Count |
---|---|
246 | |
120 | |
83 | |
74 | |
69 |