cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rsparks
Level: Powered On

How to patch a checkbox from a gallery to a Sharepoint list

I have a collection called colCarsOptions that has 4 columns. ID, car, option, and cost. Within my form is a gallery that displays the options and their cost, filtered based on whatever car model is selected in a dropdown (Dropdown8_1) further above. 

 

The filter is:

 

Filter(colCarsOptions,car = Dropdown8_1.Selected.'Vehicle Type')

 

Within the gallery, there is a checkbox. The OnCheck is: 

 

Collect(colCosts,
{
id: LookUp(colCarsOptions, car = Dropdown8_1.Selected.'Vehicle Type' && option = ThisItem.option, id),
cost: LookUp(colCarsOptions, car = Dropdown8_1.Selected.'Vehicle Type' && option = ThisItem.option, cost)
}
)

 

The OnUncheck is: 

RemoveIf(colCosts, id = ThisItem.id)

 

The OnSelect is Select(Parent).

 

The Text just displays the item name and the cost. 

 

I have a label that calculates the total costs of all the options selected, simply: Sum(colCosts, cost).

 

I then have a Submit button that when clicked, patches all the different things the user inputted, for example the Vehicle Type or the length of the lease they'd like the vehicle for. The name of the list the data is patched to is Lease Quotes.

 

The patch functions looks like this:

 

Patch('Lease Quotes', Defaults('Lease Quotes'),{'Vehicle Type': Dropdown8_1.Selected.Title}, [etc.]). 

 

How can I patch the items from the gallery? Would it be something along the lines of patching the selected options from colCarOptions? I'm not sure how to structure it. 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: How to patch a checkbox from a gallery to a Sharepoint list

Hi @rsparks ,

Do you want to merge the ForAll formula result and the first Patch formula into same row in your SP List?

 

If you want to merge the ForAll formula result and the first Patch formula into same row in your SP List, I think it is not necessary to add ForAll formula in your app.

I have made a test on my side, please take a try with the following workaround:

Set(
CurrentSubmittedRecord,
Patch('Lease Quotes', Defaults('Lease Quotes'),{'Vehicle Type': Dropdown8_1.Selected.Title}, {'Vehicle Cost': 'Total calc'.Text}, {'Lease Period': Dropdown10.Selected.Text}, {'Distance over lease': Dropdown1.Selected.Text}, {'E-tag': Dropdown2_1.Selected.Text}, {'Decal Amount': 'Decal calc'.Text}, {Insurance: 50})
);
Patch(
'Lease Quotes',
LookUp('Lease Quotes', ID = CurrentSubmittedRecord.ID),
{
'Optional Extras Package': Concat(colCosts, option & ", ")
}
); Navigate(Finish, ScreenTransition.None)

 or

Patch(
'Lease Quotes',
Defaults('Lease Quotes'),
{
'Vehicle Type': Dropdown8_1.Selected.Title,
'Vehicle Cost': 'Total calc'.Text,
'Lease Period': Dropdown10.Selected.Text,
'Distance over lease': Dropdown1.Selected.Text,
'E-tag': Dropdown2_1.Selected.Text,
'Decal Amount': 'Decal calc'.Text,
Insurance: 50,
'Optional Extras Package': Concat(colCosts, option & ", ") /* <-- Add formula here */
}
); Navigate(Finish, ScreenTransition.None)

Please take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

16 REPLIES 16
Community Support Team
Community Support Team

Re: How to patch a checkbox from a gallery to a Sharepoint list

Hi @rsparks ,

Could you please share a bit more about your scenario?

Do you want to patch all selected items from your Gallery to your 'Lease Quotes' SP List?

 

Based on the needs that you mentioned, I think the ForAll function could achieve your needs. I have made a test on my side, please consider take a try with the following workaround:

Set the OnSelect property of the "Submit" button to following:

ForAll(
             Filter(Gallery1.AllItems, Checkbox1.Value = true),
             Patch(
                        'Lease Quotes',
                         Defaults('Lease Quotes'),
                         {
                            'Vehicle Type': car,
Option: option,
Cost: cost,
... } ) )

Note: The car, option and cost are all columns from your colCarsOptions collection, which connects to your Gallery.

 

Please take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
rsparks
Level: Powered On

Re: How to patch a checkbox from a gallery to a Sharepoint list

The other data still patches, but the new snippet doesn't add anything.

 

Patch('Lease Quotes', Defaults('Lease Quotes'),{'Vehicle Type': Dropdown8_1.Selected.Title}, {'Vehicle Cost': 'Total calc'.Text}, {'Lease Period': Dropdown10.Selected.Text}, {'Distance over lease': Dropdown1.Selected.Text}, {'E-tag': Dropdown2_1.Selected.Text}, {'Decal Amount': 'Decal calc'.Text}, {Insurance: 50});

ForAll(
             Filter(Gallery2.AllItems, Checkbox6.Value = true),
             Patch(
                        'Lease Quotes',
                         Defaults('Lease Quotes'),
                         {
                             'Optional Extras Package': option
                         }
                    )
);

Navigate(Finish, ScreenTransition.None)

This is the current OnSelect of the Submit button. So the data from the first patch function still patches, it just leaves the "Optional Extras Package" column blank in the Sharepoint list. Do I have to somehow embed the new ForAll function within that first Patch?

Community Support Team
Community Support Team

Re: How to patch a checkbox from a gallery to a Sharepoint list

Hi @rsparks ,

Why do you put your first Patch formula?

Do you mean that the ForAll formula doe not work in your app? Is there something error message with it?

 

Based on the needs that you mentioned, I think the ForAll solution I provided above could achieve your needs. Within the '{}' part of the Patch function in your ForAll formula, please make sure you have specified all required fields (from your SP List) within it.

 

I assume that the Title field in your 'Lease Quotes' list is a Required field, please consider modify your formula as below:

Patch('Lease Quotes', Defaults('Lease Quotes'),{'Vehicle Type': Dropdown8_1.Selected.Title}, {'Vehicle Cost': 'Total calc'.Text}, {'Lease Period': Dropdown10.Selected.Text}, {'Distance over lease': Dropdown1.Selected.Text}, {'E-tag': Dropdown2_1.Selected.Text}, {'Decal Amount': 'Decal calc'.Text}, {Insurance: 50});
ForAll(
             Filter(Gallery2.AllItems, Checkbox6.Value = true),
             Patch(
                        'Lease Quotes',
                         Defaults('Lease Quotes'),
                         {
Title: "Specific Value for Required Title field", /* <-- Provide proper value for all required fields from your SP List here*/ 'Optional Extras Package': option } ) ); Navigate(Finish, ScreenTransition.None)

On your side, please make sure you have specified all required fields within the '{}' part of the Patch function in ForAll formula.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
rsparks
Level: Powered On

Re: How to patch a checkbox from a gallery to a Sharepoint list

@v-xida-msft  There isn't any error that occurrs, it simply fails to patch any data. Even changing from "option" to say "text example" it fails to patch over any data.

 

I also altered one of the patches to be {'Vehicle Type': Dropdown8_1.Selected.'Vehicle Type'} rather than {'Vehicle Type': Dropdown8_1.Selected.Title} which I think is what you noticed. I am unsure why it was .Title but it didn't need to be.

 

The list has no required fields so I don't think that's the issue. Unless you still think it is the issue?

 

hmm.PNG

 

Community Support Team
Community Support Team

Re: How to patch a checkbox from a gallery to a Sharepoint list

Hi @rsparks ,

Currently, I could not reproduce your issue on my side. Please add a Label within your Gallery2, set the Text property to following:

 

ThisItem.option              /* <-- Please make sure the option column value is not blank in your Gallery2 */

then check if the proper value could be displayed within the Gallery2.

 

 

Please consider take a try with the following formula:

Patch('Lease Quotes', Defaults('Lease Quotes'),{'Vehicle Type': Dropdown8_1.Selected.Title}, {'Vehicle Cost': 'Total calc'.Text}, {'Lease Period': Dropdown10.Selected.Text}, {'Distance over lease': Dropdown1.Selected.Text}, {'E-tag': Dropdown2_1.Selected.Text}, {'Decal Amount': 'Decal calc'.Text}, {Insurance: 50});
ForAll(
             RenameColumns(Filter(Gallery2.AllItems, Checkbox6.Value = true), "option", "option1"),
             Patch(
                        'Lease Quotes',
                         Defaults('Lease Quotes'),
                         {
                             'Optional Extras Package': option1
                         }
                    )
);
Navigate(Finish, ScreenTransition.None)

 or

Patch('Lease Quotes', Defaults('Lease Quotes'),{'Vehicle Type': Dropdown8_1.Selected.Title}, {'Vehicle Cost': 'Total calc'.Text}, {'Lease Period': Dropdown10.Selected.Text}, {'Distance over lease': Dropdown1.Selected.Text}, {'E-tag': Dropdown2_1.Selected.Text}, {'Decal Amount': 'Decal calc'.Text}, {Insurance: 50});
ForAll(
             Filter(Gallery2.AllItems, Checkbox6.Value = true),
             Collect(
                        'Lease Quotes',
                         {
                             'Optional Extras Package': option1
                         }
                    )
);
Navigate(Finish, ScreenTransition.None)

In addition, if the 'Optional Extras Package' column is a Choice type column in your 'Lease Quotes' list, please consider modify above formula as below:

Patch('Lease Quotes', Defaults('Lease Quotes'),{'Vehicle Type': Dropdown8_1.Selected.Title}, {'Vehicle Cost': 'Total calc'.Text}, {'Lease Period': Dropdown10.Selected.Text}, {'Distance over lease': Dropdown1.Selected.Text}, {'E-tag': Dropdown2_1.Selected.Text}, {'Decal Amount': 'Decal calc'.Text}, {Insurance: 50});
ForAll(
             Filter(Gallery2.AllItems, Checkbox6.Value = true),
             Collect(
                        'Lease Quotes',
                         {
                             'Optional Extras Package': {
Value: option
} } ) ); Navigate(Finish, ScreenTransition.None)

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
rsparks
Level: Powered On

Re: How to patch a checkbox from a gallery to a Sharepoint list

@v-xida-msft  Unfortunately the first 2 options are still not patching data. For the 3rd option, you are correct that the column type for "Optional Extra Package" is choice. 

 

Though it comes up with an error stating:

 

1.PNG

 

full.PNG

Community Support Team
Community Support Team

Re: How to patch a checkbox from a gallery to a Sharepoint list

Hi @rsparks ,

Could you please share a bit more about the first 2 options and the the 3rd option that you mentioned? What do you mean?

Could you please share a bit more the data type of the "Optional Extra Package" column in your SP List rather than in your collection?

Do you mean that the "Optional Extra Package" is both a Text type column and a Choice column in your SP list? I think it is not possible.

Could you please show more details about the data structure of your colCarsOptions collection?

 

Based on the error message that you mentioned, I think the "Optional Extra Package" column in your SP list is a Text column, please modify your formula as below:

Patch('Lease Quotes', Defaults('Lease Quotes'),{'Vehicle Type': Dropdown8_1.Selected.Title}, {'Vehicle Cost': 'Total calc'.Text}, {'Lease Period': Dropdown10.Selected.Text}, {'Distance over lease': Dropdown1.Selected.Text}, {'E-tag': Dropdown2_1.Selected.Text}, {'Decal Amount': 'Decal calc'.Text}, {Insurance: 50});
ForAll(
             Filter(Gallery2.AllItems, Checkbox6.Value = true),
             Collect(
                        'Lease Quotes',
                         {
                             'Optional Extras Package': option1
                         }
                    )
);
Navigate(Finish, ScreenTransition.None)

check if the issue is solved.

 

If the issue still exists, please comsider take a try to re-create a new app based on your data source, then try above formula I provided again, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
rsparks
Level: Powered On

Re: How to patch a checkbox from a gallery to a Sharepoint list

@v-xida-msft Sorry I've made a mistake, I have 2 Vehicle lists with similar columns. On the "Lease Quotes" list Optional Extras Package is indeed a Single Line of Text column. 

 

This is the colCarsOptions collection:

 

 

ClearCollect(colCarsOptions,
{id: 1, car: "Small Sedan", option: "First Aid Kit", cost: 100},
{id: 2, car: "Small Sedan", option: "Fire Extinguisher", cost: 50},
{id: 3, car: "Small Sedan", option: "Carpet Mats", cost: 150},
{id: 4, car: "Small Sedan", option: "Rubber Mats", cost: 150},
{id: 5, car: "Small Sedan", option: "Window Tint", cost: 400},
{id: 6, car: "Small Hatch", option: "First Aid Kit", cost: 100},
{id: 7, car: "Small Hatch", option: "Fire Extinguisher", cost: 50},
{id: 8, car: "Small Hatch", option: "Carpet Mats", cost: 150},
{id: 9, car: "Small Hatch", option: "Rubber Mats", cost: 150},
{id: 10, car: "Small Hatch", option: "Window Tint", cost: 400},
{id: 11, car: "SUV 2WD", option: "First Aid Kit", cost: 100},
{id: 12, car: "SUV 2WD", option: "Fire Extinguisher", cost: 50},
{id: 13, car: "SUV 2WD", option: "Carpet Mats", cost: 150},
{id: 14, car: "SUV 2WD", option: "Rubber Mats", cost: 125},
{id: 15, car: "SUV 2WD", option: "Window Tint", cost: 400},
{id: 16, car: "SUV 2WD", option: "Roofracks", cost: 500},
{id: 17, car: "SUV 2WD", option: "Towbar", cost: 950},
{id: 18, car: "SUV AWD", option: "First Aid Kit", cost: 100},
{id: 19, car: "SUV AWD", option: "Fire Extinguisher", cost: 50},
{id: 20, car: "SUV AWD", option: "Carpet Mats", cost: 150},
{id: 21, car: "SUV AWD", option: "Rubber Mats", cost: 125},
{id: 22, car: "SUV AWD", option: "Window Tint", cost: 400},
{id: 23, car: "SUV AWD", option: "Roofracks", cost: 500},
{id: 24, car: "SUV AWD", option: "Towbar", cost: 950},
{id: 25, car: "SUV 7 Seats", option: "First Aid Kit", cost: 100},
{id: 26, car: "SUV 7 Seats", option: "Fire Extinguisher", cost: 50},
{id: 27, car: "SUV 7 Seats", option: "Carpet Mats", cost: 130},
{id: 28, car: "SUV 7 Seats", option: "Rubber Mats", cost: 110},
{id: 29, car: "SUV 7 Seats", option: "Window Tint", cost: 320},
{id: 30, car: "Large 4WD", option: "First Aid Kit", cost: 100},
{id: 31, car: "Large 4WD", option: "Fire Extinguisher", cost: 50},
{id: 32, car: "Large 4WD", option: "Carpet Mats", cost: 150},
{id: 33, car: "Large 4WD", option: "Rubber Mats", cost: 125},
{id: 34, car: "Large 4WD", option: "Window Tint", cost: 400},
{id: 35, car: "Large 4WD", option: "Towbar", cost: 950},
{id: 36, car: "Ute", option: "First Aid Kit", cost: 100},
{id: 37, car: "Ute", option: "Fire Extinguisher", cost: 50},
{id: 38, car: "Ute", option: "Carpet Mats", cost: 165},
{id: 39, car: "Ute", option: "Rubber Mats", cost: 125},
{id: 40, car: "Ute", option: "Window Tint", cost: 340},
{id: 41, car: "Ute", option: "Towbar", cost: 750},
{id: 42, car: "Ute", option: "Soft Tonneau", cost: 490},
{id: 43, car: "Ute", option: "Hard Tonneau with lock", cost: 2840},
{id: 44, car: "Ute", option: "Tubliner", cost: 540},
{id: 45, car: "People Mover", option: "First Aid Kit", cost: 100},
{id: 46, car: "People Mover", option: "Fire Extinguisher", cost: 50},
{id: 47, car: "People Mover", option: "Carpet Mats", cost: 300},
{id: 48, car: "People Mover", option: "Rubber Mats", cost: 300},
{id: 49, car: "People Mover", option: "Window Tint", cost: 295}
);
Set(varReset,true);
Set(varReset, false);
Set(varReset, true);
Clear(colCosts)

I'm not sure what the functions at the bottom do, I just copied them from a solution someone created for me. The code above sits in the OnVisible of the screen the form is on. 

 

Unfortunately that code still does not fix the issue. Are you sure the code is meant to have "option1" rather than "option"? Though even trying it with "option" it doesn't want to work. 

 

Also, I can get the data to patch over the most recently selected checkbox using the code:

 

{'Optional Extras Package': Gallery2.Selected.option}

But the issue is, say for example I select Fire Extinguisher, Window Tint and Towbar. It will only patch the most recently selected checkbox (in this instance Towbar).

 

Community Support Team
Community Support Team

Re: How to patch a checkbox from a gallery to a Sharepoint list

Hi @rsparks ,

Please make sure you have added proper SP List as data source in your app.

 

Please take a try with the following formula within your app:

Set the Items property of the Gallery (Gallery2) to following:

Filter(colCarsOptions,car = Dropdown8_1.Selected.'Vehicle Type')

Set the OnSelect property of the "Submit" button to following:

Patch([@'Lease Quotes'], Defaults([@'Lease Quotes']),{'Vehicle Type': Dropdown8_1.Selected.Title}, {'Vehicle Cost': 'Total calc'.Text}, {'Lease Period': Dropdown10.Selected.Text}, {'Distance over lease': Dropdown1.Selected.Text}, {'E-tag': Dropdown2_1.Selected.Text}, {'Decal Amount': 'Decal calc'.Text}, {Insurance: 50});
ForAll(
             RenameColumns(Filter(Gallery2.AllItems, Checkbox6.Value = true), "option", "option1"),
             Patch(
                        [@'Lease Quotes'],
                         Defaults([@'Lease Quotes']),
                         {
..., 'Optional Extras Package': option1
... } ) ); Navigate(Finish, ScreenTransition.None)

Please make sure you have added a proper data source in your app, and then use it in above Patch formula.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (6,307)