Hi there,
Im currently creating an app that allows academics to enter units they teach on. For each unit, there can be multiple delivery styles (lectures, tutorials etc) that can be applied to a single unit. So, for example, you can have "Unit 1", and that unit can include lectures, tutorials and workshops. how I'm currently making it work:
What my current app requires, however, if for someone to add the same unit multiple times for each delivery style. On the backend, this works great for me because it means my data is easy to sort when I export it from the SP list where it's stored. But for the user, I feel it makes it quite clunky.
It would be great to make it so that you can add one unit, with multiple delivery styles before you press submit, but it would appear in the sharepoint list in a way that means I can still work with it.
If anyone has any ideas, I would really appreciate it. Hopefully I've explained it properly. An idea of how i would like it to work is below:
Matt
Thankyou for that! That's exactly what I'm looking for! If the Sharepoint list that I'm using later gets replaced with a database, will the patch still work?
HI @EpicTriffid ,
Could you please share a bit more about your scenario?
Do you want to add one unit with multiple delivery styles before you press submit button to submit it to your SP list?
If you want to add one unit with multiple delivery styles before you press submit button to submit it to your SP list, I think the combination of Collection, ForAll function and Patch function could achieve your needs.
On your side, you could save the Units records from your SP list into a Collection when you load your app, then use the Collection as data source within your Gallery. When you add new Unit record via pressing a "+" button, you need to add record into this Collection firstly. When you press the "Submit" button, patch all new records within your Gallery into your SP list together.
I have made a test on my side, please take a try with the following workaround:
Set the OnStart property of the App control to following:
ClearCollect(LocalUnitRecords, 'YourSPList')
set the Items property of the Gallery to following:
LocalUnitRecords
Add a "+" button along side the "Submit" button, set the OnSelect property of the "+" icon to following:
Patch( LocalUnitRecords, Defaults(LocalUnitRecords), { UnitName: UnitNameTextBox.Text, UnitSize: UnitSzieDropdownBox.Selected.Value, DeliveryStyle: DeliveryStyleDropdownBox.Selected.Value, Hours: HoursTextBox.Text, ... } )
Set the OnSelect property of the "Submit" button to following:
ForAll( RenameColumns(Gallery1.AllItems, "UnitName", "UnitName1", "DeliveryStyle", "DeliveryStyle1"), If( IsBlank(LookUp('YourSPList', UnitName = UnitName1 && DeliveryStyle = DeliveryStyle1)), Patch( 'YourSPList', Defaults('YourSPList'), { UnitName: GalleryUnitNameBox.Text, DeliveryStyle: GalleryDeliveryStyleBox.Selected.Value, ... } ) ) );
Refresh('YourSPList');
ClearCollect(LocalUnitRecords, 'YourSPList')
Note: The GalleryUnitNameBox, GalleryDeliveryStyleBox, ... represents the Text Input box, Dropdown box, ... within the Gallery (Gallery1). The Gallery1 represents the Gallery in your app.
More details about the ForAll function and Patch function, please check the following article:
Best regards,
WarrenBelz
146,522
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,890
Most Valuable Professional