Hi,
I need a help with my powerapps Gallery, I have a customized gallery named "TripRecord" which also has 4 input fields, '+' and 'X' icons to add and delete a record.
input1- from location: dropdown, input2- To location: dropdown, input3- from date: datepicker, input4- to date: datepicker
what I want the gallery to do as below,
ex: consider the first record items is selected as below
fromdropdown1: Canada Todropdown1: Mexico
Fromdate1: 1/01/2020 todate1: 2/01/2020
and in the second record of the gallery, I want the Fromdropdown2 to get the value from Todropdown1 to be auto populated as below and let the user choose the values for the rest of the fields.
Fromdropdown2: Mexico (auto populate Mexico) todropdown2:
Fromdate2: todate2:
Solved! Go to Solution.
Hi @ZenHen :
I've made a test but it worked well.
Please try adding a unique identifier "ID" to TripRecord.For Example:
ClearCollect(TripRecord,{Input1:"",Input2:"",Input3:Today(),Input4:Today()})
1\Add a gallery and set it's Items proeprty to(Sort the items displayed in the Gallery in ascending order😞
Sort(TripRecord,ID)
2\Add two drop down controls into this gallery(fromdropdown/Todropdown)
Set fromdropdown:
Items
["","Canada","Mexico","US","UK"]
OnChange
Patch(TripRecord,ThisItem,{Input1:fromdropdown.SelectedText.Value})
Default
ThisItem.Input1
Set Todropdown:
Items
["","Canada","Mexico","US","UK"]
OnChange
Patch(TripRecord,ThisItem,{Input2:Todropdown.SelectedText.Value})
Default
ThisItem.Input2
3\Add two date picker controls into this gallery(Fromdate/Todate)
Set Fromdate
OnChange
Patch(TripRecord,ThisItem,{Input3:Fromdate.SelectedDate})
DefaultDate
ThisItem.Input3
Set Todate
OnChange
Patch(TripRecord,ThisItem,{Input4:todate.SelectedDate})
DefaultDate
ThisItem.Input4
4\Add an "Add" icon and an "Rubbish-bin" icon
Add icon-OnSelect
Patch(TripRecord,Defaults(TripRecord),{ID:Last(Sort(TripRecord,ID)).ID+1,Input1:Todropdown.SelectedText.Value})
Rubbish-bin icon-OnSelect
Remove(TripRecord,ThisItem)
The principle of my solution is:
1: When adding a new item: Use the Todropdown.SelectedText.Value of the current record as the value of the Input1 field of the new record.
2: When displayed, the default value of the To drop-down box of the new item is the value of Input1, so it will display the Todropdown.SelectedText.Value of the previous record by default
Best Regards,
Bof
Hi @ZenHen :
I've made a test for your reference:
My data source-TripRecord:
ClearCollect(TripRecord,{Input1:"",Input2:"",Input3:Today(),Input4:Today()})
1\Add a gallery and set it's Items proeprty to:
TripRecord
2\Add two drop down controls into this gallery(fromdropdown/Todropdown)
Set fromdropdown:
Items
["","Canada","Mexico","US","UK"]
OnChange
Patch(TripRecord,ThisItem,{Input1:fromdropdown.SelectedText.Value})
Default
ThisItem.Input1
Set Todropdown:
Items
["","Canada","Mexico","US","UK"]
OnChange
Patch(TripRecord,ThisItem,{Input2:Todropdown.SelectedText.Value})
Default
ThisItem.Input2
3\Add two date picker controls into this gallery(Fromdate/Todate)
Set Fromdate
OnChange
Patch(TripRecord,ThisItem,{Input3:Fromdate.SelectedDate})
DefaultDate
ThisItem.Input3
Set Todate
OnChange
Patch(TripRecord,ThisItem,{Input4:todate.SelectedDate})
DefaultDate
ThisItem.Input4
4\Add an "Add" icon and an "Rubbish-bin" icon
Add icon-OnSelect
Patch(TripRecord,Defaults(TripRecord),{ID:CountRows(TripRecord)+1,Input1:Todropdown.SelectedText.Value})
Rubbish-bin icon-OnSelect
Remove(TripRecord,ThisItem)
Best Regards,
Bof
Hello Bof,
Thankyou very much for your response, i followed your steps, but unfortunately it did not give me the result i wanted. i want the to country to be auto populated as from country in the second entry as shown in the below image.
Hi @ZenHen :
I've made a test but it worked well.
Please try adding a unique identifier "ID" to TripRecord.For Example:
ClearCollect(TripRecord,{Input1:"",Input2:"",Input3:Today(),Input4:Today()})
1\Add a gallery and set it's Items proeprty to(Sort the items displayed in the Gallery in ascending order😞
Sort(TripRecord,ID)
2\Add two drop down controls into this gallery(fromdropdown/Todropdown)
Set fromdropdown:
Items
["","Canada","Mexico","US","UK"]
OnChange
Patch(TripRecord,ThisItem,{Input1:fromdropdown.SelectedText.Value})
Default
ThisItem.Input1
Set Todropdown:
Items
["","Canada","Mexico","US","UK"]
OnChange
Patch(TripRecord,ThisItem,{Input2:Todropdown.SelectedText.Value})
Default
ThisItem.Input2
3\Add two date picker controls into this gallery(Fromdate/Todate)
Set Fromdate
OnChange
Patch(TripRecord,ThisItem,{Input3:Fromdate.SelectedDate})
DefaultDate
ThisItem.Input3
Set Todate
OnChange
Patch(TripRecord,ThisItem,{Input4:todate.SelectedDate})
DefaultDate
ThisItem.Input4
4\Add an "Add" icon and an "Rubbish-bin" icon
Add icon-OnSelect
Patch(TripRecord,Defaults(TripRecord),{ID:Last(Sort(TripRecord,ID)).ID+1,Input1:Todropdown.SelectedText.Value})
Rubbish-bin icon-OnSelect
Remove(TripRecord,ThisItem)
The principle of my solution is:
1: When adding a new item: Use the Todropdown.SelectedText.Value of the current record as the value of the Input1 field of the new record.
2: When displayed, the default value of the To drop-down box of the new item is the value of Input1, so it will display the Todropdown.SelectedText.Value of the previous record by default
Best Regards,
Bof
Stay up tp date on the latest blogs and activities in the community News & Announcements.
Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST
Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.
User | Count |
---|---|
10 | |
9 | |
3 | |
2 | |
1 |
User | Count |
---|---|
33 | |
25 | |
22 | |
8 | |
3 |