web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Apps
Unanswered

Toggle

(0) ShareShare
ReportReport
Posted on by Super User 2024 Season 1

Hi 

 

i have a collection which is collecting repeating table but i wanted to add toggle so when i selected it carry to the collection so when i submit via ForAll it only show the records ticked i mean the toggle only ON those record i have ticked, here is screen shot 

 

Thanks 

 

i wanted to add toggle to the code of collecting the collection below
 Collect(ExpenseCollection,{LineTracking: "",LineNumberPackages:"",LineWeight:0,LineCodAmount1:"",LineLength:"",LineWidth:"",LineHeight:"",LineDeclaredValue:0,LineFreightCharges:0,ShowSaveButton: true})

 

collection.png

Categories:
I have the same question (0)
  • Ben-Western Profile Picture
    77 on at

    Hi @Ramole ,

     

    I would create an extra column called {tobepatched: toggle.value} and then you would be able to filter() where tobepatched is "true" or "yes" 

     

    then perform a forall() for that result.

     

    Hope this helps!

     

    Regards,

     

    Benjamin Western | Automation Specialist

    NextStep Creations

     

    Taking your PowerApps Skill the NextStep

  • Ben-Western Profile Picture
    77 on at

    Hi @Ramole ,

     

    Actually just thinking you could just patch() based on an if statement for each page

    Therefore you code would be similar to below:

    If(toggle.value, Patch(datasource, defaults(datasource), {item: "content}))

     

     

    Hope this helps!

     

    Regards,

     

    Benjamin Western | Automation Specialist

    NextStep Creations

     

    Taking your PowerApps Skill the NextStep

     

  • v-xida-msft Profile Picture
    on at

    Hi @Ramole ,

    Do you want to add the Toggle control within your repeating table (Gallery)?

    Do you want to save the corresponding item to the collection when you checked the Toggle?

     

    Based on the needs that you mentioned, I think you could consider insert the Toggle control inside the Gallery (repeating table). Then you could tick the Toggle control for each item in your repeating table Gallery.

    Note: I assume you design your repeating table using Gallery control

     

    Set the OnSelect property of the Toggle control within the repeating Table Gallery to following:

    If(
     Toggle1.Value,
     Collect(
     ExpenseCollection,
     {
     LineTracking: LineTrackingTextBox.Text,
     LineNumberPackages: LineNumberPackagesTextBox.Text,
     LineWeight: LineWeightTextBox.Text,
     LineCodAmount1: LineCodAmount1TextBox.Text,
     LineLength: LineLengthTextBox.Text,
     LineWidth: LineWidthTextBox.Text,
     LineHeight: LineHeightTextBox.Text,
     LineDeclaredValue: LineDeclaredValue,
     LineFreightCharges: LineFreightChargesTextBox.Text,
     ShowSaveButton: true
     }
     ),
     RemoveIf(
     ExpenseCollection,
     LineTracking = LineTrackingTextBox.Text
     )
    )

    Note: I assume that the LineTracking represents the Primary Key column in your ExpenseCollection. On your side, you must make sure there is a Primary Key column existed in your ExpenseCollection to identify each record uniquely.

     

    After that, you could apply the ForAll function to the ExpenseCollection to execute other operations, e.g. write data back to your data source.

     

    Best regards,

  • Ramole Profile Picture
    Super User 2024 Season 1 on at

    Hi @v-xida-msft 

     

    Thanks but the toggle is only part of the data, example i only click the toggle if this shipment is COD otherwise i dont click THE TOGGLE  and it will show the record this shipment is not COD , and it records my SharePoint list, but my aim is when i select the toggle it only record under that record and the one i have not selected doesn't show on the record please have look the screen shot

     

    Thanks 

     

    cod.pngshare.png

  • v-xida-msft Profile Picture
    on at

    Hi @Ramole ,

    Yeah, I think I have understand your issue correctly -- you want to save these records whose Toggle control has been ticked back to your SP List, all right?

     

    If you want to save these records whose Toggle control has been ticked into a collection firstly, I think the solution I provided above could achieve your needs. Set the OnCheck property of the Toggle control within the repeating Table Gallery to following:

    Collect(
     ExpenseCollection,
     {
     LineTracking: LineTrackingTextBox.Text,
     LineNumberPackages: LineNumberPackagesTextBox.Text,
     LineWeight: LineWeightTextBox.Text,
     LineCodAmount1: LineCodAmount1TextBox.Text,
     LineLength: LineLengthTextBox.Text,
     LineWidth: LineWidthTextBox.Text,
     LineHeight: LineHeightTextBox.Text,
     LineDeclaredValue: LineDeclaredValue,
     LineFreightCharges: LineFreightChargesTextBox.Text,
     ShowSaveButton: true
     }
     )

    set the OnUncheck property of the Toggle to following to following:

    RemoveIf(
     ExpenseCollection,
     LineTracking = LineTrackingTextBox.Text
    )

     

    Actually, I think it is not necessary to initialize a collection to collect these records Toggle control has been ticked from your Gallery, a Filter function is enough. Please consider take a try with the following formula:

    ForAll(
     Filter(Gallery1.AllItems, Toggle1.Value = true), // filter these records whose Toggle control has been ticked from your Gallery 
     Patch( // saving data back to your SP List...
     'Your SP List',
     Defaults('Your SP List'),
     {
     CODAmountColumn: CODAmountTextBox.Text,
     FreightChargesColumn: FreightChargesTextBox.Text,
     ...
     ...
     }
     )
    )

     

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

     

    Best regards,

  • Ramole Profile Picture
    Super User 2024 Season 1 on at

    Hi @v-xida-msft 

     

    Yeah correct, but i would like to save all records the only makes different the toggle press is it shows the ticked toggle record is COD otherwise all it still records and back end SharePoint will show yes or no,

    i hope that makes sense.

     

    Thanks 

  • v-xida-msft Profile Picture
    on at

    Have you taken a try with the formula I provided above?

     

    The Filter function within above ForAll formula I provided would filter these records/items whose Toggle control has been checked from your repeating Table gallery. Then it would save these filtered result back to your SP List.

     

    If you just want to save all Gallery Items back to your SP List, and record different value for checked toggle and unchecked toggle in your SP List, please modify above formula as below:

    ForAll(
     Gallery1.AllItems, // filter these records whose Toggle control has been ticked from your Gallery 
     Patch( // saving data back to your SP List...
     'Your SP List',
     Defaults('Your SP List'),
     {
     CODAmountColumn: CODAmountTextBox.Text,
     FreightChargesColumn: FreightChargesTextBox.Text,
     ToggleField: If( // add formula here
     Toggle1.Value,
     "COD",
     "NOT COD"
     ),
     ...
     }
     )
    )

    Note: The ToggleField represents the field in your SP list, to store the Toggle display value

    ForAll(
     Gallery1.AllItems, // filter these records whose Toggle control has been ticked from your Gallery 
     Patch( // saving data back to your SP List...
     'Your SP List',
     Defaults('Your SP List'),
     {
     CODAmountColumn: CODAmountTextBox.Text,
     FreightChargesColumn: FreightChargesTextBox.Text,
     ToggleField: If( // add formula here
     Toggle1.Value,
     Toggle1.TrueText,
     Toggle1.FalseText
     ),
     ...
     }
     )
    )

     

    Best regards,

    Hi @Ramole ,

  • Ramole Profile Picture
    Super User 2024 Season 1 on at

    Hi @v-xida-msft 

    I have tried but no luck, i dont know what mistake am doing,  below code it does patch the toggle value with record thats fine but my aim is on individual record selected only  as now it does record on all records not only the one i selected please have look my ForAll code here see if you can modified please 

     

    ForAll(
    ExpenseCollection,
    If(
    !IsBlank(LineTracking),
    Patch(
    'Shipments ',Defaults('Shipments '),

    {
    TrackingNumber: LineTracking,
    ShippingFee: LineFreightCharges,
    Weight: LineWeight,
    Length: LineLength,
    Width: LineWidth,
    Height: LineHeight,
    DeclaredValue: LineDeclaredValue,
    CodAmount:Value(LineCodAmount1),

    Company: DataCardValue2.Selected,
    OrderDate: DataCardValue3.SelectedDate,
    Payment_x0020_Method: DataCardValue22.Selected,
    ShippingMethod: DataCardValue8.Selected,
    ShippingRoute: DataCardValue9.Selected,
    Status: DataCardValue10.Selected,
    CODCollectionType:DataCardValue14.Selected,
    TotalPieces: Value(DataCardValue60.Text),
    Collect_x0020_on_x0020_delivery_: Toggle2.Value,
    Check_x0020_Number: DataCardValue23.Text,
    Employee: DataCardValue1.Selected,
    DueDate: DataCardValue17.SelectedDate,
    InvoiceNumber: DataCardValue61.Text

     

    }
    )
    )
    );Notify("Data saved successfully!",Success); Navigate(scr_ProjectDashboard,UnCover)

     

     

    Thanks 

  • v-xida-msft Profile Picture
    on at

    Hi @Ramole ,

    Please consider modify your formula as below:

    ForAll(
     RepeatingTableGallery.AllItems,
     If(
     !IsBlank(LineTracking),
     Patch(
     'Shipments ',
     Defaults('Shipments '),
     {
     TrackingNumber: LineTracking,
     ShippingFee: LineFreightCharges,
     Weight: LineWeight,
     Length: LineLength,
     Width: LineWidth,
     Height: LineHeight,
     DeclaredValue: LineDeclaredValue,
     CodAmount: Value(LineCodAmount1),
     Company: DataCardValue2.Selected,
     OrderDate: DataCardValue3.SelectedDate,
     Payment_x0020_Method: DataCardValue22.Selected,
     ShippingMethod: DataCardValue8.Selected,
     ShippingRoute: DataCardValue9.Selected,
     Status: DataCardValue10.Selected,
     CODCollectionType: DataCardValue14.Selected,
     TotalPieces: Value(DataCardValue60.Text),
     Collect_x0020_on_x0020_delivery_: If( // Add formula here
     Toggle2.Value,
     "COD",
     "Not COD"
     ),
     Check_x0020_Number: DataCardValue23.Text,
     Employee: DataCardValue1.Selected,
     DueDate: DataCardValue17.SelectedDate,
     InvoiceNumber: DataCardValue61.Text
     }
     )
     )
    );
    Notify("Data saved successfully!",Success); Navigate(scr_ProjectDashboard,UnCover)

    or

    ForAll(
     RepeatingTableGallery.AllItems,
     If(
     !IsBlank(LineTracking),
     Patch(
     'Shipments ',
     Defaults('Shipments '),
     {
     TrackingNumber: LineTracking,
     ShippingFee: LineFreightCharges,
     Weight: LineWeight,
     Length: LineLength,
     Width: LineWidth,
     Height: LineHeight,
     DeclaredValue: LineDeclaredValue,
     CodAmount: Value(LineCodAmount1),
     Company: DataCardValue2.Selected,
     OrderDate: DataCardValue3.SelectedDate,
     Payment_x0020_Method: DataCardValue22.Selected,
     ShippingMethod: DataCardValue8.Selected,
     ShippingRoute: DataCardValue9.Selected,
     Status: DataCardValue10.Selected,
     CODCollectionType: DataCardValue14.Selected,
     TotalPieces: Value(DataCardValue60.Text),
     Collect_x0020_on_x0020_delivery_: If( // Add formula here
     Toggle2.Value,
     Toggle2.TrueText
     Toggle2.FalseText
     ),
     Check_x0020_Number: DataCardValue23.Text,
     Employee: DataCardValue1.Selected,
     DueDate: DataCardValue17.SelectedDate,
     InvoiceNumber: DataCardValue61.Text
     }
     )
     )
    );
    Notify("Data saved successfully!",Success); Navigate(scr_ProjectDashboard,UnCover)

     

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

     

    Best regards,

  • Ramole Profile Picture
    Super User 2024 Season 1 on at

    Hi @v-xida-msft 

    I am getting this error please have look the screen shot 

     

    Thank you so much.

    erro10r.png

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard