cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JayashreeKrish
Resolver II
Resolver II

Validation in gallery Control in canvas App

1) I have a gallery , by default I am not able to see the first row, I have to click "+" to see first row. How can I make it visisble on the load of the page ?

 

JayashreeKrish_0-1629309689514.png

I have to click "+" for this to appear 

JayashreeKrish_1-1629309722537.png

 

2) The code in my Save &Close button is 

Once I click , the values are stored in a string and sent to another screen,

 

Set(AllPrincipalString,Concat(Gallery1.AllItems,Concatenate(TextInput1.Text,"; ",TextInput2.Text,"; ",TextInput3.Text,"; ",TextInput4.Text,"; ",TextInput5.Text,"; ",TextInput6.Text,"; ",TextInput7.Text,"; ",TextInput8.Text,"; ",TextInput9.Text," | ")));

Notify("Principal Added successfully!",NotificationType.Success);

Navigate(Screen1,ScreenTransition.Cover);

 

But I want the user to user to prevent from submitting if my TextInput1.Text, is empty how can i do that ?

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
rubin_boer
Super User
Super User

@JayashreeKrish may i suggest you set the displaymode of the button based on your rule.

 

Select the display button and set its display mode to

If(
    CountRows(
        Filter(
            YourGallery.AllItems,
            IsBlank(yourTextBox)
        )
    ) > 0,
    DisplayMode.Disabled,
    DisplayMode.Edit
)

 

now when its empty the user will get a disabled button

rubin_boer_0-1629315876098.png

and once there is data it will be active

rubin_boer_1-1629315902164.png

 

hope thi shelps

View solution in original post

10 REPLIES 10
JayashreeKrish
Resolver II
Resolver II

I tried with 

ForAll(Gallery1.AllItems,If(Not(IsBlank(TextInput1.Text)),Edit,Disabled))

in DisplayMode of Button

But it shows - Enum expected

rubin_boer
Super User
Super User

Hi @JayashreeKrish when you create the collection for the gallery, add blanks to it. By default, your gallery is empty and i assume you user collect to add the rows. 

 

This will add a row with blank for two items

ClearCollect(colMyInput,{p_name:Blank(), p_title:Blank()})

add that to the OnVisible property of the screen. you will get this when the screen opens

rubin_boer_0-1629313145269.png

Now for the second part. you are using a gallery, is the plan to have more than one entry? once i know this i will suggest a way forward. your variable collecting the string that way from the gallery is a bit troublesome, id like to get more into that.

 

hope this helps you

Thanks much @rubin_boer 

My Question 1 is answered

 

rubin_boer
Super User
Super User

@JayashreeKrish may i suggest you set the displaymode of the button based on your rule.

 

Select the display button and set its display mode to

If(
    CountRows(
        Filter(
            YourGallery.AllItems,
            IsBlank(yourTextBox)
        )
    ) > 0,
    DisplayMode.Disabled,
    DisplayMode.Edit
)

 

now when its empty the user will get a disabled button

rubin_boer_0-1629315876098.png

and once there is data it will be active

rubin_boer_1-1629315902164.png

 

hope thi shelps

For my Question 2,

 

Once my gallery is loaded,

If I add value in Principal Name field , I should be able to save all the Principal Names in  a field in Screen 1 separated by semicolon 

 

If it is empty I should  I should  not be able to save anything in   a field in Screen 1 , it should be blank as it is 

Thanks much @rubin_boer  

Both my questions are answered 🙂

rubin_boer
Super User
Super User

@JayashreeKrish you may want to investigate to save the collection itself and then patch your datasource with the collection. a good place will be the "+" icon. have a look at this whihc is a very good piece by @mdevaney PATCH Multiple Records In Power Apps 10x Faster - Matthew Devaney

Hi @rubin_boer  

 

For my first question.

I have a canvas app with two screen

On screen 1, if i click on a button it will go to screen 2 which is having gallery

In screen 2  i have a gallery , with clear , save&close , close button.

 

 

on load of screen it should show the first entry if it is blank  (it is showing since i put the below code)

JayashreeKrish_0-1629465992651.png

 

But  if I  had entered some value ,

when i come to screen 2 from screen 1 , it should show the value  

JayashreeKrish_1-1629466038015.png

But it is not shown as expected when i use the below code

If I use   the below it is always blank - ClearCollect(colMyInput,{p_name:Blank(), p_title:Blank()})

How do I avoid that ?

anupp
New Member

is it possible to do validation for item level in gallery.

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

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.

Users online (1,914)