Hello,
Screen 1:
I have two dropdowns:
Company Name, and Company Branch.
Screen 2:
The gallery that will filter based on what's selected.
I have assigned onChange property of the dropdown Company Branch to navigate the user to screen 2.
The issue is as follow:
When the user selects the FIRST value from the Company Branch nothing happens which means it doesn't navigate the user to screen 2.
But let's say, I have selected the second value I will be redirected and if I get back to select the First value also it will work.
Assume a company has only one branch so if he selects the branch he will not be redirected.
I was thinking to set a default blank value "" to the dropdown so starting from the second it will show the branches. But how this can be done?
Please find below the assigned functions for the Company Branch:
Items:
Filter('Companies Branches', CompanyName = DataCardValue8.Selected.'Company Name').Branch
OnChange:
Navigate(Visits,ScreenTransition.Cover);
I am trying to find a solution to redirect the user even if the dropdown contains only one value.
Please find below a demo:
Can please someone explain in detail and provides an example to achieve the above scenario?
Any help will be greatly appreciated.
Thank you!
Solved! Go to Solution.
Hi Julien.
You make local collection because its easy to add a new temporary item for this list.
You said you want to make a OnChange code where the app navigate to another screen. But if you only have one Branch, the user will not be able to change this, thus the onChange will not run.
To do this you had a plan to add a blank value as default on Branch so the user must change the dropdown. (sounds like a plan :)).
To get this blank value you need it in the source of the items of the dropdown. If you dont have many branches, I would recomend to load all of them in a local collection in OnStart. You can also make it on change on the company dropdown.
If you make it on onStart (all branches) Items in the branch dropdown must be filter(_Brances;comapny=dopanydropdown.selected.companyName).
If you make it in OnChange you can do ClearCollect(_Branches;filter(_Brances;comapny=dopanydropdown.selected.companyName)).
To get the "blank" option (or you can make a input help tekst for the user as this option like "Choose branch" as a choice. )
To get this in you collection, you use Collect(_Branches;{companyName:Blank() (or "Choose branch").
One Example:
I made 2 SP list for this example
If you refer to the list direct you will get dropdown like this: (Please note i used listbox for better to show how its done.
To get a blank choice (or with some text, I used "<select branch>"
Run this code in OnChange on the Company dropdown
ClearCollect(
_Branch;
Filter(
Branch;companyID=ListBox1.Selected.ID
)
);;
Collect(
_Branch;
{
ID:0;
Title:"<Choose Branch>";
companyID:ListBox1.Selected.ID
}
)
And you will get dropdown box like this:
The user should now see the default with a message that he/she needs to choose a Branch.
Now you can have a OnChange code on the Branch Dropdown that sends the user to the right screen.
In general I will always recommend to first collect all you data into collections i powerapps and use the local collection as data. This is much faster than directly working with the lists. You need to add som update / refresh if you have a system with multiple users where changes occur often, but that is minor compare to the speed you gain. (Of course, if its a very simple app with 2-5 list, you might not get much of the speed, but bigger app is about useless when working directly with lists.
I hope this was a bit clearer 🙂
Best regards
Tommy
Hi Julien2
Start making a local collection of your branches
ClearCollect(
_companiesBraches(
Filter(
'Companies Branches';
CopanyName=DataCardValue8.Selected.'Company name')
)
)
Collect(
_companiesBranches(
{
'Company Name':Blank()
}
)
Change your items to the local collection and default to "" or Blank()
Good luck 🙂
Tommy
Hi @TurboTape ,
Thanks for your reply.
Where do I have to initialize the local collection(because on the Items property of the dropdown I get an error)?
Regarding the Collect, you mentioned why are you assigning the Company Name column to be blank?
Could you please provide a real example?
Looking forward to your response.
Hi Julien.
You make local collection because its easy to add a new temporary item for this list.
You said you want to make a OnChange code where the app navigate to another screen. But if you only have one Branch, the user will not be able to change this, thus the onChange will not run.
To do this you had a plan to add a blank value as default on Branch so the user must change the dropdown. (sounds like a plan :)).
To get this blank value you need it in the source of the items of the dropdown. If you dont have many branches, I would recomend to load all of them in a local collection in OnStart. You can also make it on change on the company dropdown.
If you make it on onStart (all branches) Items in the branch dropdown must be filter(_Brances;comapny=dopanydropdown.selected.companyName).
If you make it in OnChange you can do ClearCollect(_Branches;filter(_Brances;comapny=dopanydropdown.selected.companyName)).
To get the "blank" option (or you can make a input help tekst for the user as this option like "Choose branch" as a choice. )
To get this in you collection, you use Collect(_Branches;{companyName:Blank() (or "Choose branch").
One Example:
I made 2 SP list for this example
If you refer to the list direct you will get dropdown like this: (Please note i used listbox for better to show how its done.
To get a blank choice (or with some text, I used "<select branch>"
Run this code in OnChange on the Company dropdown
ClearCollect(
_Branch;
Filter(
Branch;companyID=ListBox1.Selected.ID
)
);;
Collect(
_Branch;
{
ID:0;
Title:"<Choose Branch>";
companyID:ListBox1.Selected.ID
}
)
And you will get dropdown box like this:
The user should now see the default with a message that he/she needs to choose a Branch.
Now you can have a OnChange code on the Branch Dropdown that sends the user to the right screen.
In general I will always recommend to first collect all you data into collections i powerapps and use the local collection as data. This is much faster than directly working with the lists. You need to add som update / refresh if you have a system with multiple users where changes occur often, but that is minor compare to the speed you gain. (Of course, if its a very simple app with 2-5 list, you might not get much of the speed, but bigger app is about useless when working directly with lists.
I hope this was a bit clearer 🙂
Best regards
Tommy
Hi @TurboTape ,
It was clear. Thank you for a such detailed reply.
Regards,
Julien
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
User | Count |
---|---|
180 | |
51 | |
47 | |
32 | |
32 |
User | Count |
---|---|
266 | |
91 | |
78 | |
68 | |
67 |