cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
amralomari
Helper III
Helper III

Patch multiple columns from multiple checbox

Dears 

 

I've an application where user choses couple of periods, using Mr. Reza's tutorial Here I've succefully convert the drop list into checkboxes.

 

This application submites the data into a SP list, in that list there are durations columns (duration 1, duration 2 ...etc.)

 

The next step is that I want submit button to update the durations column per chosen columns; for example if the user chose "3 months & 6 months", either the 1st and the 2nd columns are updated or the 3 months & 6 months columns will be updated with a date with 3 months in advance and 6 months in advance from the chosen "incubation date".

 

What I used to do before is to update the future date for 1 time period (as the gif attached) using the following:-

 

Table( { Name: "1 Week", Days: 7 },
{ Name: "2 Weeks", Days: 14 },
{ Name: "1 Month", Days: 30 },
{ Name: "2 Months", Days: 60 },
{ Name: "3 Months", Days: 90 },
{ Name: "6 Months", Days: 180 },
{ Name: "9 Months", Days: 270 },
{ Name: "12 Months", Days: 365 },
{ Name: "24 Months", Days: 730 },
{ Name: "36 Months", Days: 1095 } )

 

And the following formula in the Update field in the data picker

 

DateValue2.SelectedDate + Time(Value(HourValue2.SelectedText.Value), Value(MinuteValue2.SelectedText.Value), 0)

 

 

Now I don’t care showing the future date but I want when the user choses 3 periods, 3 dates will be updated in the SP list.

 

3 ACCEPTED SOLUTIONS

Accepted Solutions
v-bofeng-msft
Community Support
Community Support

Hi @amralomari :

Do you want to get multiple items after selecting multiple options in the combo box and add these items to the data source?

If so,I've made a test for your reference:

1\My combo box (ComboBox2)

Items

Table( { Name: "1 Week", Days: 7 },
{ Name: "2 Weeks", Days: 14 },
{ Name: "1 Month", Days: 30 },
{ Name: "2 Months", Days: 60 },
{ Name: "3 Months", Days: 90 },
{ Name: "6 Months", Days: 180 },
{ Name: "9 Months", Days: 270 },
{ Name: "12 Months", Days: 365 },
{ Name: "24 Months", Days: 730 },
{ Name: "36 Months", Days: 1095 } )

2\Submit button

With(
    {
        StartDate: DateValue2.SelectedDate + Time(Value(HourValue2.SelectedText.Value),Value(MinuteValue2.SelectedText.Value),0)
    },
    ForAll(
        ComboBox2.SelectedItems As TheTabel, 
        Patch(
           YourDataSource,
           Defaults(YourDataSource),
           {
           'Incubation Date': StartDate,
           'Stability Conditions': DateAdd(StartDate,TheTabel[@Days],Days)
           }
        )
    )
)

Best Regards,

Bof

View solution in original post

@amralomari ,

A couple of thoughts here

  • Why are you referring to time (in Start Date) when you are adding days to the result - are you wanting the same time on the target field?
  • I would suggest you rename Days in the drop-down something else (suggestion below)
  • SelectedText is Deprecated and may not work in the future - use Selected.
  • Try .SelectedItems.Period (renamed as above) in the formula

 

With(
   {
      StartDate: 
      DateValue2.SelectedDate + 
      Time(
         Value(HourValue2.Selected.Value),
         Value(MinuteValue2.Selected.Value),
         0
      )
   },
   ForAll(
      ComboBox2.SelectedItems.Period As TheTabel,
      Patch(
         YourDataSource,
         Defaults(YourDataSource),
         {
            'Incubation Date': StartDate,
            'Stability Conditions': 
            DateAdd(
               StartDate,
               TheTabel.Period,
               Days
            )
         }
      )
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

@amralomari ,

This was not straight-forward (nearly raised the white flag a couple of times), but I have this working - firstly, you had two reserved words in your combo box, so I used this

Table(
    {Period: "1 Week", Span: 7},
    {Period: "2 Weeks", Span: 14},
    {Period: "1 Month", Span: 30},
    {Period: "2 Months", Span: 60},
    {Period: "3 Months", Span: 90},
    {Period: "6 Months", Span: 180},
    {Period: "9 Months", Span: 270},
    {Period: "12 Months", Span: 365},
    {Period: "24 Months", Span: 730},
    {Period: "36 Months", Span: 1095}
)

then your collect code

With(
   {
      wDays: 
      AddColumns(
         ComboBox2.SelectedItems,
         "AddDays",
         Value(Span)
      ),
      wDate: DateValue2.SelectedDate
   },
   ForAll(
      wDays,
      Patch(
         'Stability Conditions',
         Defaults('Stability Conditions'),
         {
            'Incubation Date': wDate,
            'Stability Conditions': 
            DateAdd(
               wDate,
               AddDays,
               Days
            )
         }
      )
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

View solution in original post

25 REPLIES 25
v-bofeng-msft
Community Support
Community Support

Hi @amralomari :

Do you want to get multiple items after selecting multiple options in the combo box and add these items to the data source?

If so,I've made a test for your reference:

1\My combo box (ComboBox2)

Items

Table( { Name: "1 Week", Days: 7 },
{ Name: "2 Weeks", Days: 14 },
{ Name: "1 Month", Days: 30 },
{ Name: "2 Months", Days: 60 },
{ Name: "3 Months", Days: 90 },
{ Name: "6 Months", Days: 180 },
{ Name: "9 Months", Days: 270 },
{ Name: "12 Months", Days: 365 },
{ Name: "24 Months", Days: 730 },
{ Name: "36 Months", Days: 1095 } )

2\Submit button

With(
    {
        StartDate: DateValue2.SelectedDate + Time(Value(HourValue2.SelectedText.Value),Value(MinuteValue2.SelectedText.Value),0)
    },
    ForAll(
        ComboBox2.SelectedItems As TheTabel, 
        Patch(
           YourDataSource,
           Defaults(YourDataSource),
           {
           'Incubation Date': StartDate,
           'Stability Conditions': DateAdd(StartDate,TheTabel[@Days],Days)
           }
        )
    )
)

Best Regards,

Bof

amralomari
Helper III
Helper III

Thanks a lot dear Bof

 

Unfortunately I had some errors when I tried to emplement the code above for the OnSelect formula

 

amralomari_0-1617189744432.png

 

also for the close [X] icon OnVisible formula

amralomari_1-1617190131253.png

 

could you please help me at these errors?

Hi @amralomari :

Q1:Unfortunately I had some errors when I tried to emplement the code above for the OnSelect formula.

Could you tell me what Checkbox3 is?Is it a Checkbox control instead of a combo box control?

Q2:also for the close [X] icon OnVisible formula

Please try 

Form1.Mode <> FormMode.New

Best Regards,

Bof

amralomari
Helper III
Helper III

Yes it's a checkbox, as below:-

 

amralomari_0-1617254395829.png

 

Thanks for the close icon 👍

Hi @amralomari :

In the information you provided earlier, it is mentioned that you are using a combo box.

1.JPG

So the solution I provided is based on combo box.

2.JPG


I suggest you use combo box instead of check box

Best Regards,

Bof

amralomari
Helper III
Helper III

Sorry my bad, thought both will work.

 

Anyway I'm still facing some issues with the patch function

 

amralomari_0-1617260436407.png

Could you please elaborate for a solution, thanks in advance.

Hi @amralomari :

Could you tell me the wrong information?
Could you show me the data structure of'products List'?

I think your formula may be missing some required fields:


With(
{
StartDate: DateValue2.SelectedDate + Time(Value(HourValue2.SelectedText.Value),Value(MinuteValue2.SelectedText.Value),0)
},
ForAll(
ComboBox2.SelectedItems As TheTabel,
Patch(
YourDataSource,
Defaults(YourDataSource),
{

Column1:XXX,

Column2:xxx,

'Incubation Date': StartDate,
'Stability Conditions': DateAdd(StartDate,TheTabel[@Days],Days)
}
)
)
)

 

 

 

Best Regards,

Bof

amralomari_0-1617265017676.png

 

I'm very sorry, the period column was a choice column not a Date&Time, so I've changed to Date&Time and the error was solved

But the data still not patched to the list

 

the duration columns are "period 1" -> "period 10"

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Users online (1,280)