cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sajarac
Kudo Kingpin
Kudo Kingpin

Block an user selection

Hello Community.

 

I hope someone can point me in the right direction.

 

Please refer to the diagram below of what I am trying to accomplish. 

Here is my situation. I have a label "Master Contracts" and I have a secondary label "# of Contracts" for the number in the secondary label is the amount of records that the user has to create.

I have a dropdown with a "Sequence" formula to get the max value of the label "LblNumberContracts"

also I have a button to create a new contract and this button patch my share point list.

and a "gallery1" that shows the contracts that has been assigned so far. 

 

What I would like to do is to disable the Button in case the number selected in the dropdown is present in the gallery. Scenario 1. or disable the same button but in this case show a table or gallery with all the contracts and "gray out" those who has been assigned.

 

Picture1.png

 

Thanks in advance for any advice,

 

Regards.

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User III
Super User III

@sajarac 

The simplest thing to do is just compare to the Gallery.

So the DisplayMode of the button would be the following:

If(Dropdown.Selected.Value in Gallery1.AllItems.SubNumber, Disabled, Edit)

I don't know what the number is in your Gallery, but if the name is not right ("SubNumber") in the above formula, then replace it with the correct column name from your Gallery (this would be the item that your LblSubNumber is based on).

 

Some other notes based on the prior replies and original post:

1) Your Dropdown Items should be : Sequence(Value(LblNumberOfContracts.Text))

2) From a user interface perspective, you might consider changing your Dropdown to only include numbers that do NOT exist in the Gallery already.
Filter(Sequence(Value(LblNumberOfContracts.Text)), !(Value in Gallery1.AllItems.SubNumber))

3) Don't use .SelectedText on dropdown controls as it is a deprecated property.

 

_____________________________________________________________________________________
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
rubin_boer
Super User
Super User

hi there @sajarac  you can use the Countrows(YourGallery.AllItems) to get the number of added contracts and set the button to disable once it reaches the number of contracts

the buttons display: if(countrows(gallery.allitems) = NumberOtContracts, disabled,edit)

The matrix which you want to display. does it need to be created dynamically, what is the maximum number of contract that is to be created, that should be displayed this way?

 

Here is an idea. The number of contracts is a collection:

The Add Contract is populating the gallery (Gallery3)when a new contract is added in your case.

ClearCollect(_NumberOfContracts,SEQUENCE(# of contracts))

The gallery's datasource is set to _NumberOfContracts

The gallery's wrapcount is set to 5

The label is added to the gallery with the fill: If(Value(Self.Text) <= CountRows(Gallery3.AllItems),LightGray,White)

the label color is set to: If(Value(Self.Text) <= CountRows(Gallery3.AllItems),DarkGray,Black)

rubin_boer_0-1612723754925.png

the matrix will change as the contract count is increased. when it reaches 20 the button will be disabled using the previous code.

 

hope this helps!

 
 

Hey thank you very much for your prompt response. Very cool solution. I just have a small issue here. Th problem is not the number of contracts. I need to match the values.

 

Let me I explain:

 

In my dropdown I select the contract, in this case contract number = 4. If the number 4 is present in my gallery1 I would like to set the display mode of my button to disable.

 

Let me know and thanks again for your help.

 

Regards,

rubin_boer
Super User
Super User

@sajarac  Ok Got it, just to make sure the gallery is a different dataset not the data being built from adding the new contracts. 

  1. Dropdown: Select 4
  2. Gallery connected to DataSource Contracts
  3. Button DisplayMode: If(CountRows(LookUp( Contracts, HeaderOfContract = CDropDown.SelectedText.Value)) = 0, true, false)

 

 

Hi, the formula still complaining or I don't get it. Sorry

 

sajarac_0-1612790835328.png

 

RandyHayes
Super User III
Super User III

@sajarac 

The simplest thing to do is just compare to the Gallery.

So the DisplayMode of the button would be the following:

If(Dropdown.Selected.Value in Gallery1.AllItems.SubNumber, Disabled, Edit)

I don't know what the number is in your Gallery, but if the name is not right ("SubNumber") in the above formula, then replace it with the correct column name from your Gallery (this would be the item that your LblSubNumber is based on).

 

Some other notes based on the prior replies and original post:

1) Your Dropdown Items should be : Sequence(Value(LblNumberOfContracts.Text))

2) From a user interface perspective, you might consider changing your Dropdown to only include numbers that do NOT exist in the Gallery already.
Filter(Sequence(Value(LblNumberOfContracts.Text)), !(Value in Gallery1.AllItems.SubNumber))

3) Don't use .SelectedText on dropdown controls as it is a deprecated property.

 

_____________________________________________________________________________________
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

Hey, thank you very much for your help.

I am getting in the displayMode property of my button:

Can't convert this data type. Power Apps can't convert this Number to a Control.

 

RandyHayes
Super User III
Super User III

@sajarac 

You are not specifying the actual value, you are specifying a Control. 

Can you provide a sceenshot of the formula with error?  I assume it is on the Gallery1.AllItems.SubNumber 

_____________________________________________________________________________________
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!
sajarac
Kudo Kingpin
Kudo Kingpin

I am so sorry, I have been dealing with this for so long. That is why.

a Big thank you!!!

 

RandyHayes
Super User III
Super User III

@sajarac 

So is everything working for you now?  

_____________________________________________________________________________________
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.

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (41,020)