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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Text validation on Gal...
Power Apps
Unanswered

Text validation on Gallery using a collection

(0) ShareShare
ReportReport
Posted on by

Hi all,
I have a collection called ColShipping Orders, 

I am using the upload image control to add files to a gallery, that items property is set to the colShipping Orders.

The upload image control has this on the button - on the onSelect property:

 

Collect(colShippingOrders,{Title:AddFileBtn.FileName,DataStream:ImageControl.Image})

 

Now I have a button outside the gallery, called upload documents (this button will run a flow that will upload the gallery document to and SP library.)

I want to disable this button when the title2 label field in the gallery contains an illegal SP character such as an '&'

So on the displayMode of the button I have put the following if statement:
If("&" in colShippingOrders.Title,DisplayMode.Disabled,DisplayMode.Edit)

However when I click the add file button and upload a file with an & in its name it doesn't disable. Any ideas what I' doing wrong?




 

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    153,127 Most Valuable Professional on at

    Hi @Darren137227 ,

    I have a blog on this subject that should be of assistance.

     

    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.

  • Darren137227 Profile Picture
    on at

    Hi Warren,

    I have created the collection but not really sure where to put the rest of the code:

    ForAll( colChar, If( FieldNo in Self.Text, Collect( colError, {CharError: true} ); Reset(Self) ) )

    I have no on change on my text box.

    I have a text label called Title2 inside the gallery, which captures the file name when added to my gallery, which is hooked up to a collection.

    On my button (outside of the gallery), I just need to adjust display mode (disable it) when the Title2 label has one of the characters from the colchar collection you gave me.
    I tried:

    If(colChar.FieldNo in Title2.Text,DisplayMode.Disabled,DisplayMode.Edit)

    but gave me formula error of cannot use table values in this context.
    Sorry, a bit new to canvas apps....

  • WarrenBelz Profile Picture
    153,127 Most Valuable Professional on at

    Hi @Darren137227 ,

    Sorry I missed your post - it is all in the blog - the first bit is on the OnChange of the Text box - there has to be one there if this is the type of control. The second bit unfortunately has a many-to-many relationship (any character in the box needs to be checked against any record in the collection, so that will not work - you would need to simply drop the Reset(Self) and have the DisplayMode as 

    If(
     CountRows(colError)>0,
     DisplayMode.Disabled,
     DisplayMode.Edit
    )

     

    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.

     

     

  • Darren137227 Profile Picture
    on at

    Hi Warren,
    I have followed your instruction but it doesn't seem to be working. So far I have:
    On Form screen 1 (on visible) I have:
    ClearCollect(
    colChar,
    ForAll(
    Sequence(15),
    {FieldNo: Char(32 + Value)}
    ),
    ForAll(
    Sequence(7),
    {FieldNo: Char(57 + Value)}
    ),
    ForAll(
    Sequence(5),
    {FieldNo: Char(90 + Value)}
    ),
    ForAll(
    Sequence(4),
    {FieldNo: Char(122 + Value)}
    )
    )


    Then on the text input control in my gallery I have for the OnChange property:


    ForAll(
    colChar,
    If(
    FieldNo in Self.Text,
    Collect(
    colError,
    {CharError: true}
    );

    )
    )

     

    and for the display mode of the text input control I have:
    If(
    CountRows(colError)>0,
    DisplayMode.Disabled,
    DisplayMode.Edit
    )
    However, when I upload a text file with an '&' in the file name the text input field can still be edited.

    Am I missing something?
     

  • WarrenBelz Profile Picture
    153,127 Most Valuable Professional on at

    Hi @Darren137227 ,

    I have not tested your deviation to the blog process. but please do some basic debugging such as a label with CountRows(colError) and see when it goes above zero - which is should when you press enter with a Special Character in the input.

  • Darren137227 Profile Picture
    on at

    Hi Warren I have added a label for de bugging and can see that the on change isn’t firing. The reason is because it’s populated from the title label in the gallery. It’s default is set to ThisItem. Title. The gallery items get populated by a collection that gets added to when I click an add image button that’s been customised to add file binary data. The text label of the gallery is set to the file name and I’ve added a text input to the gallery (for the on change property) I need a way to fire the syntax on the on change property when an item is added to the gallery / my collection. If that makes sense

  • WarrenBelz Profile Picture
    153,127 Most Valuable Professional on at

    HI @Darren137227 ,

    I am not actually sure how you would do that, but you need to check if any of the characters in the collection are in the target text - maybe on the AddImage button.

     

    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.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard