Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Unanswered

When checkbox is selected add row in gallery

(1) ShareShare
ReportReport
Posted on by 559

Hi all,

I have two galleries Phase gallery(1st) which has check box which when selected it will add row into the next gallery. On "+" icon rows are added to the second gallery. 

On + code:

ForAll(
Sequence(countitems) As Sequence Number,
Collect(
colFinalPhase,
{
ID: Last(colFinalPhase).ID + 1,
'Project Name': prjnames_3.Selected.ProjectName,
Phase: Title2_4.Text, --(When check box is selected that respect phase value will be collected in the label)
'Work Product/Process': Last(
FirstN(
ComboBox6_5.SelectedItems,
SequenceNumber.Value
)
).'Work Product/Process'
}));

On check of check box: Set(countitems,0);Set(countitems,Sum(CountRows(ComboBox6_5.SelectedItems),countitems));

When user selected 2 check box at the same time the last selected check box alone display in the label. My requirement is when user selects 2 check box at the same time both the Phases(1st gallery) must be displayed in the Phase label and rows will be added based on the selected value.

 

Any help/suggestion on this.

Thanks in advance.

 

Categories:
  • Sri Profile Picture
    559 on at
    Re: When checkbox is selected add row in gallery

    @M_Ali_SZ365 ,

    On check of the checkboxes the code which I gave I have attached as screenshot. Different Phase loads for each project.  is the one in the Phase gallery(Label) which displays all the Phases value. 

    Combo box items: Filter(
    Work_Product_Master,
    PhaseNames = Title2_4.Text(Label which holds the Phases)
    ).'Work Product/Process'

    On Uncheck property: 

    I gave the code and it is giving me error: Remove(SelectedPhases, ThisItem)

    "Incompatible type. The collection can't contain values of this type."

  • M_Ali_SZ365 Profile Picture
    1,110 on at
    Re: When checkbox is selected add row in gallery

    @Uthhra ,

    Try This 

    To add rows to a second gallery based on selected checkboxes and ComboBox values, use this approach:

    For the Checkbox OnCheck and OnUncheck properties:

    Add the phase to a collection with ComboBox values when checked:

    Collect(colSelectedPhases, {Phase: ThisItem.Phase, RelatedItems: ComboBox.SelectedItems})

    Remove the phase from the collection when unchecked:

    Remove(colSelectedPhases, LookUp(colSelectedPhases, Phase = ThisItem.Phase))

    For the ComboBox OnChange property:

    Update the related items in colSelectedPhases for the respective phase:

    Patch(colSelectedPhases, LookUp(colSelectedPhases, Phase = ThisItem.Phase), {RelatedItems: ComboBox.SelectedItems})

    On "+" icon press:

    Use nested ForAll to iterate over selected phases and their related items to add to the second gallery:

    ForAll(
    colSelectedPhases,
    ForAll(
    RelatedItems,
    Collect(
    colFinalPhase,
    {
    ID: Last(colFinalPhase).ID + 1,
    'Project Name': prjnames_3.Selected.ProjectName,
    Phase: Phase,
    'Work Product/Process': 'Work Product/Process' // Replace with actual field
    }
    )
    )
    );

     

     

    _________________________________________________________________________________________________________________________

    If my post helped, please mark it as Accept as solution to help others find it. A Thumbs Up would also be appreciated if you found it useful. 

    Warm regards,
    Muhammad Ali

     

     

  • Sri Profile Picture
    559 on at
    Re: When checkbox is selected add row in gallery

    Hi @M_Ali_SZ365 

    As per your code I cannot give ForAll (Selected Phases) because when checkbox is checked there is a combo box which loads values and I am using sequence to count items from the combo box when checkbox is checked. 

  • M_Ali_SZ365 Profile Picture
    1,110 on at
    Re: When checkbox is selected add row in gallery

    Hi @Uthhra ,

    To add rows in a second gallery based on selected checkboxes in the first gallery:

    Collect selected phases when a checkbox is checked:

    Collect(SelectedPhases, {Phase: ThisItem.Phase})

    Remove unselected phases when a checkbox is unchecked:

    Remove(SelectedPhases, ThisItem)

    On "+" icon press, add collected phases to the second gallery:

    ForAll(
    SelectedPhases,
    Collect(
    colFinalPhase,
    {
    ID: Last(colFinalPhase).ID + 1,
    'Project Name': prjnames_3.Selected.ProjectName,
    Phase: Phase
    // Add other fields as needed
    }
    )
    )

    Replace ThisItem.Phase with the actual data field from your first gallery and adjust field names as per your schema.

    Fuel our success! 🚀 Give a thumbs up and click 'Solution Accepted' to supercharge our community. Your actions speak volumes!
    Warm regards,
    Muhammad Ali

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,552 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,928 Most Valuable Professional

Leaderboard