Skip to main content

Notifications

Power Platform Community / Forums / Building Power Apps / How do you delete a si...
Building Power Apps
Unanswered

How do you delete a single person in a multi select person or group column?

Posted on by 320

I am using a sharepoint list as a datasource and I want to delete a single person in the column only if
the person' name isnt mentioned in the combo box of the edit screen.

I currently have this formula:

RemoveIf(
                AttachmentParticipants, 
                CID = locCurrentRecord.ID
);   
 

for example. my list has a column named "Participants" and its a multi select person or group column
in the list I have ID = 200 and person named Winter and Snow.

in the edit screen the user plans to edit the person to Winter and Happy. That means in the "Participants" column I have to remove Snow and retain Winter.

How do I do this?

I have another list which I did something similar but, in this list, the Participants is not multi select meaning it creates an item per participant. In this formula what I did was check if the person mentioned in the list is in the select items of the edit screen's combo box then remove that list item if it doesn't.

ParticipantsResponse and AttachmentParticipants are different lists.

ForAll(
                //ClearCollect(colExistingParticipant, Filter(ParticipantResponse, cID= locCurrentRecord.ID));
                colExistingParticipant As ExistingParticipant, 
                If(
                    //if review participants select in combobox is not existing in the filtered participantcontractresponse list
                    Not( ExistingParticipant.Participant.DisplayName in ForAll(
ReviewParticipantsDataCardValue7_Edit
.SelectedItems, DisplayName)), //condition
                    RemoveIf(
                        ParticipantResponse, 
                        cID= ExistingParticipant.ContractID && (Participant.DisplayName = ExistingParticipant.Participant.DisplayName)
                    );
                
                    
                );
                
            );
  • KevinGador Profile Picture
    KevinGador 320 on at
    How do you delete a single person in a multi select person or group column?
    WarrenBelz -

    I do apologize when I posted this question my brain cells were all destroyed in the process of trying to make this work. 

     
    • So are you also trying to remove the values from fields from ParticipantsResponse or are you iterating through this updating the matching ProjectID fields in AttachmentParticipants ?
      And where does the source list come into this exercise ? I have a feeling that what you want to do is not really possible, but I need to clearly understand what you want before I attempt any more model/coding exercises. 
      Yes. I am also removing from ParticipantsResponse but since this is a single person field, I can freely remove them once they are not in the combo box. 

      I have already achieved this and does not need any more suport for the ParticipantsResponse list.

      See code below. 

       
       


      What I need help on is actually dealing with the AttachmentParticipant list with 3 multi select person columns to check.

      the problem is that AttachmentParticipants columns are multi select person which you have previously said that RemoveIf won't work if I am aiming to remove only 1 person and retain the others 

      I am also thinking of the possibly to just create a flow where it will check if the Review Participants of the source list is changed/modified which I think can be easier but since I've dived deeper into this formula pool might as well continue with it?.


       
  • WarrenBelz Profile Picture
    WarrenBelz 142,305 on at
    How do you delete a single person in a multi select person or group column?
    OK - no wonder I was confused. Please just take a moment to read your original post and then see where we are now and you may understand.
    The first bit was the structure I perceived from the start (apart form the wrong list and field name)
    The destination field that is to be updated is the AttachmentParticipants list which is a dependent list with a lookup ContractID , ideally what I need is to remove all the existing Participants in the list that are not currently in the combo box selected items. For example, a user wants to edit an item and the combo box automatically brings up Winter and Snow. User modifies the review participants to Winter and Elsa.

    Now we have three columns and this is probably the show-stopper - you would have to run the code three times (one for each field) as we are already down in the depths of many-to-many filtering.
    I have then to check whether Snow is existing in the AttachmentParticipants list NotRequiredParticipants, ReviewParticipants and ReviewedParticipants

    However as well (maybe my grey matter is getting the same colour and volume as my scant allocation of hair), but we have only dealt with the AttachmentParticipants with the fields now mentioned. So are you also trying to remove the values from fields from ParticipantsResponse or are you iterating through this updating the matching ProjectID fields in AttachmentParticipants ?
    And where does the source list come into this exercise ? I have a feeling that what you want to do is not really possible, but I need to clearly understand what you want before I attempt any more model/coding exercises. 

    MarkBandR, please feel free to have a go at this with what we have learnt so far.
  • KevinGador Profile Picture
    KevinGador 320 on at
    How do you delete a single person in a multi select person or group column?
    WarrenBelz - Hello! I deeply apologize for having to cause you some inconvenience with my app. Hope your brain fully recovers any time soon :) The power platform world needs you :) 

    Please see the answers below
    • Where is the source values field that the user chooses
      I am in editing screen, the source values are from choices using the source list. Users can change this by selecting multiple person. 

       
      Choices([@'Source List'].'Review Participants')

    • Where is the destination field to be updated

      The destination field that is to be updated is the AttachmentParticipants list which is a dependent list with a lookup ContractID , ideally what I need is to remove all the existing Participants in the list that are not currently in the combo box selected items. For example, a user wants to edit an item and the combo box automatically brings up Winter and Snow. User modifies the review participants to Winter and Elsa. 

      I have then to check whether Snow is existing in the AttachmentParticipants list NotRequiredParticipants, ReviewParticipants and ReviewedParticipants columns , if Snow exists I have to remove them because the user has updated the participants. 
    • What is the relationship between the two lists

      There are actually 3 lists. 
      1 source list 
      1 ParticipantsResponse - dependent on source list via ContractID
      1 AttachmentParticipants - dependent on source list via ContractID

      ParticipantResponse - creates a list item per Review Participants 
      AttachmentParticipants - create a list item per attachments and puts in every participants in a column. Default one they go to is ReviewParticipants

       
    • Which is iterating through the other
    • How (if all) does the list with the single selection field come into this ?


      ParticipantResponse - creates a list item per Review Participants 

      For example, the source list have review participants as Winter and Snow. It will create 2 list items for the list
      with same id as source list as ContractID 


      1 for winter 1 for snow. But this has all been taken care of, all I need now is for the AttachmentParticipants removal and updating.


    MarkBandR - I had a reply that wasnt posted. So I'll just have to answer you again

    this is what I intended to do: 

    Should every user selected in SourceParticipants (or your combo box) be set in the ReviewParticipants field? (Winter, Snow changes to Snow, Casper)

    ​​​​​​​I appreciate you taking the time to help me as well :)


     
  • WarrenBelz Profile Picture
    WarrenBelz 142,305 on at
    How do you delete a single person in a multi select person or group column?
    Before my brain melts from the shifting sands of list and field references, can you please confirm exactly (List and Field names)
    • Where is the source values field that the user chooses
    • Where is the destination field to be updated
    • What is the relationship between the two lists
    • Which is iterating through the other
    • How (if all) does the list with the single selection field come into this ?
    MarkBandR I also appreciate your brain on this - it is all about iterating through the destination and only keeping those values present in the source, then patching the result back to the destination. As both are Complex field types, you need to get both down to Tables structured only on the values in those fields.BTW - it is not a tag - just a formatted copy of the user's reference at the top.
     
  • MarkBandR Profile Picture
    MarkBandR 770 on at
    How do you delete a single person in a multi select person or group column?
    Hi Kevin,
     
    I spent quite a bit of time this morning trying to duplicate what you are doing. And I am also trying to learn from Warren on the formula examples he has provided.
     
    I have a Source List that has a multi select person field.
     
    I have an AttachmentParticipants list that has a multi select person field.
     
    I have a ParticipantResponse list that has a single person field.
     
     
    You provided this example:
    for example my source list initial participants were Winter and Snow, then when I modify it to Snow, Casper 
    the AttachmentParticipant, ReviewParticipants should be Snow and Casper not Winter and Snow. (arrangement doesnt matter)
     
    Are you doing Intersection or Duplication?
     
    If your example is accurate, you are doing duplication. The ReviewParticipants field in AttachmentParticipants is a copy of the users selected for SourceParticipants. You are removing Winter and adding Casper. ReviewParticipants is updated to be equal to SourceParticipants. If you were doing an Intersection, you would just be removing Winter. You would not be adding Snow.
     
    Which are you doing? Should every user selected in SourceParticipants (or your combo box) be set in the ReviewParticipants field? (Winter, Snow changes to Snow, Casper) Or is it Intersection? (Winter, Snow becomes just Snow)
     
    For the ParticipantResponse List, the easiest thing to do would be to remove all items for the ContractID and add back the users selected. 
     
    The next option would be to remove/delete the item for Winter and add a new item for Casper.
     
    A harder option would be to update the Winter item to Casper. I saythis is the harder option because what if you have a different case:
    source list initial participants were Winter and Snow, then when I modify it to Snow, Casper, Blizzard, and Frost 
    the AttachmentParticipant, ReviewParticipants should be Snow, Casper, Blizzard, and Frost not Winter and Snow. 
     
    In this case (and using the hardest option), you would need to update 1 item and add 2 new items.
     
    I am assuming that the Participants is not a fixed number.
     
    This is the third time I am trying to post this. I had been using Chrome as my browser but this morning every reply I post is dropped.
     
    -Mark
     
    PS - Hi Warren, Thanks for all the tips. I also want to know how you are referencing user's in your replies. You use to be able to use the "@" symbol. I can't seem to figure it out.
  • KevinGador Profile Picture
    KevinGador 320 on at
    How do you delete a single person in a multi select person or group column?
    oh that seems to be the problem, 

    my existing participant list or should I call ParticipantResponse list doesnt have a multi select person column enabled. Its just a single person column 

    Just to summarize, 

    Source List = the one created with the combo box, multi select person enabled

    AttachmentParticipants = dependent list lookup through ContractID, multi select person enabled, will add the partcipants entered in the source list as ReviewParticipants 

    ParticipantResponse = dependent list lookup through ContractID, multi select person disabled, will add each participants as a list item since multi select is disabled ( for example I have Winter and Snow, Each Participant counts as 1 list item) 

    I have the edit functionality for ParticipantResponse list working, its just that the AttachmentParticipants list is kinda hard for me. 
    I don't know how I will remove a person listed in a multi select person column, though I get your solution makes perfect sense I just can't implement it properly to work... I've been trying to modify it to work but no luck. 

    So for example my source list initial participants were Winter and Snow, then when I modify it to Snow, Casper 

    the AttachmentParticipant, ReviewParticipants should be Snow and Casper not Winter and Snow. (arrangement doesnt matter)
  • WarrenBelz Profile Picture
    WarrenBelz 142,305 on at
    How do you delete a single person in a multi select person or group column?
     
    Works perfectly here as far as having no errors.
     
    • colExistingAttachmentParticipant has two fields involved - ID (Number) and Participant (Multi-choice Person Column)
    • ReviewParticipantsDataCardValue7_Edit is a multi-choice People picker Combo Box with the Items Choices(ExistingParticipant.Participant)
    • ExistingParticipant has two fields involved here ID (Number) and Participant (Multi-choice Person Column)
  • KevinGador Profile Picture
    KevinGador 320 on at
    How do you delete a single person in a multi select person or group column?
    Apologies for this @warren :) Thnks for the response. 

    errors were found :( I fried my brain cells too :| 

    I cant type _Current As _C , it doesnt bring up Email. 











     
  • WarrenBelz Profile Picture
    WarrenBelz 142,305 on at
    How do you delete a single person in a multi select person or group column?
     
    Your Initial post referenced a record with an ID of 200, so I built a model using your actual list, field and control names to resolve this rather complex many to many filter involving a multi-value field type. The output was as expected. This may work (it will take a while to run), but I cannot test it.
     
    ForAll(
       colExistingAttachmentParticipant As _Item,
       With(
          {
             _Current: LookUp(
                ExistingParticipant,
                ID = _Item.ID,
                Participant
             ),
             _New: ReviewParticipantsDataCardValue7_Edit.SelectedItems
          },
          With(
             {
                _Update: Ungroup(
                   ForAll(
                      _Current As _C,
                      Filter(
                         _New,
                         _C.Email in Email
                      )
                   ),
                   Value
                )
             },
             Patch(
                ExistingParticipant,
                {
                   ID: _Item.ID,
                   Participant: ForAll(
                      _Update As _U,
                      {
                         Claims: _U.Claims,
                         Department: _U.Department,
                         DisplayName: _U.DisplayName,
                         Email: _U.Email,
                         JobTitle: _U.JobTitle,
                         Picture: _U.Picture
                      }
                   )
                }
             )
          )
       )
    )

    Please click Does this answer your question 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 a Like.
    MVP (Business Applications)     Visit my blog Practical Power Apps    Buy me a coffee


  • KevinGador Profile Picture
    KevinGador 320 on at
    How do you delete a single person in a multi select person or group column?
    @Warren 

    I have tried this code below but it doesnt remove or update the list based on the selected items of the combo box
     
    With( 
                    {
                        _Current: 
                        LookUp( 
                            colExistingAttachmentParticipant, 
                            ID = locCurrentRecord.ID, 
                            ReviewParticipants
                        ), 
                        _New: ReviewParticipantsDataCardValue7_Edit.SelectedItems
                    }, 
                    With(
                        { 
                            _Update: 
                            Ungroup( 
                                ForAll(
                                    _Current As _C, 
                                    Filter( 
                                        _New, 
                                        _C.Email in Email
                                    )
                                ), 
                                Value
                            )
                        }, 
                        ForAll(
                            colExistingAttachmentParticipant As CurrentAttachmentItem, 
                            UpdateIf( 
                                AttachmentParticipants, 
                                ContractID = CurrentAttachmentItem.ContractID && (Title = CurrentAttachmentItem.Title), 
                                {
                                    ReviewParticipants: 
                                    ForAll( 
                                        _Update As _U, 
                                        { 
                                            Claims: _U.Claims, 
                                            Department: _U.Department, 
                                            DisplayName:  _U.DisplayName, 
                                            Email: _U.Email, 
                                            JobTitle: _U.JobTitle, 
                                            Picture: _U.Picture 
                                        }
                                    )
                                }
                            )
                        )
                    )//attachment participant patching inner with end bracket
                );//attachment participant patching outer with end bracket
     

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

September 2024 Newsletter…

September 2024 Community Newsletter…

Community Update Sept 16…

Power Platform Community Update…

Tuesday Tip #2 Global Search…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 142,305

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 63,566

Leaderboard