cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
marial16
Post Partisan
Post Partisan

parent child data using collections

Hallo,

I have created a demo app and i am not using any forms. Just fields and i am using Collect to save the data to collections.

there is a uniqueID which is produced.

From a combo box field i want to add participants (this should be the child list).

the items of the combo box is Office365Users.SearchUser({searchTerm:personDD.SearchText,top:100})

On the OnChange property i make a Collection. Collect(colTravelParticipants, personDD.Selected);

Then i am using a button to add a column for the ParentID in order to connect the participants with the Parent record.

OnSelect: Collect(colTravelParticipantsWithID,ShowColumns(AddColumns(colTravelParticipants,"ParentID",var_uniqueID),"DisplayName","Mail","Department","ParentID")).

The problem is that every time i am creating a new record and adding participants, the Parent ID in the colTravelParticipantsWithID, gets updated (including Previous records with the previous uniqueID) so i am getting All records with the same unique ID.

 

Any ideas ?

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-jefferni
Community Support
Community Support

Hi @marial16 ,

 

The issue is you are AddColumns and ShowColumns each time you click the button to add parentID. The two functions will loop all the source table. They should use only once to change the structure of a table.

 

Please try below steps:

1. OnChange of Combo box:

ClearCollect(
    colTravelParticipants,
    personDD.Selected
);
Collect(
    colTravelParticipantsWithID,
    AddColumns(
        ShowColumns(
            colTravelParticipants,
            "DisplayName",
            "Mail",
            "Department"
        ),
        "ParentID",
        ""
    )
)

 

2. OnSelect of add ID button:

Patch(
    colTravelParticipantsWithID,
    LookUp(
        colTravelParticipantsWithID,
        DisplayName = personDD.Selected.DisplayName
    ),
    {ParentID: var_uniqueID}
)

 

Hope this helps.

 

Best regards,

Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.

Community Support Team _ Jeffer Ni

If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

1 REPLY 1
v-jefferni
Community Support
Community Support

Hi @marial16 ,

 

The issue is you are AddColumns and ShowColumns each time you click the button to add parentID. The two functions will loop all the source table. They should use only once to change the structure of a table.

 

Please try below steps:

1. OnChange of Combo box:

ClearCollect(
    colTravelParticipants,
    personDD.Selected
);
Collect(
    colTravelParticipantsWithID,
    AddColumns(
        ShowColumns(
            colTravelParticipants,
            "DisplayName",
            "Mail",
            "Department"
        ),
        "ParentID",
        ""
    )
)

 

2. OnSelect of add ID button:

Patch(
    colTravelParticipantsWithID,
    LookUp(
        colTravelParticipantsWithID,
        DisplayName = personDD.Selected.DisplayName
    ),
    {ParentID: var_uniqueID}
)

 

Hope this helps.

 

Best regards,

Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.

Community Support Team _ Jeffer Ni

If this post helps, then please consider Accept it as the solution to help the other members find it.

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.

Top Kudoed Authors
Users online (2,902)