cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sasrsc1966
Resolver I
Resolver I

ComboBox, Single & Multi-Person, DefaultSelectedItems and Patch NOT in a form - Example

This has taken me days to work out (because of my own typos), mainly through trying to piece it together but also through the community board. I thought I'd present it like this from my own notes to help others. If you disagree then please provide feedback. 
I will say that one of the things that really got me was Mail vs. Email. Oh boy, was that an epiphany, SP stores it as Email while the table needed in Office365 is Mail.

 

This is an example for a Power App - Canvas App - with a ComboBox directly on the canvas and not in a form. The data connection is to a SP List.

 

Single Person is a SP Person/People Column (only allows single entry)

Multiple Person is a SP Person/People Column (allows multiple entries)

 

Property

Single Person

Multiple Person

ComboBox Name

ComboBox1

ComboBox2_1

DefaultSelectedItems

Office365Users.SearchUser({searchTerm: varItem.PersonSingle.Email})

 

---Or---

 

{

    Claims:"i:0#.f|membership|" & Lower(varItem.PersonSingle.Email),

    Department:"",

    DisplayName:varItem.PersonSingle.DisplayName,

    Mail:varItem.PersonSingle.Email,

    JobTitle:".",

    Picture:"."

}

 

ForAll(varItem.PersonMultiple,

{

    Claims:"i:0#.f|membership|" & Lower(Email),

    Department:"",

    DisplayName: DisplayName,

    Mail:Email,

    JobTitle:".",

    Picture:"."

})

Items

Office365Users.SearchUser({searchTerm: ComboBox1.SearchText})

Office365Users.SearchUser({searchTerm: ComboBox2_1.SearchText})

DisplayFields

["DisplayName"]

["DisplayName"]

IsSearchable

true

true

SearchFields

["DisplayName"]

["DisplayName"]

SelectMultiple

false

true

Patch (triggered by a button)

Patch(

    'Test List',

    LookUp(

        'Test List',

        ID = varItem.ID

    ),

    {

        PersonSingle: {

            Claims:"i:0#.f|membership|" & Lower(ComboBox1.Selected.Mail),

            Department: "",

            DisplayName: ComboBox1.Selected.DisplayName,

            Email: Lower(ComboBox1.Selected.Mail),

            JobTitle: "",

            Picture: ""

        }

    }

);

Patch(

    'Test List',

    LookUp(

        'Test List',

        ID = varItem.ID

    ),

    {

        PersonMultiple: ForAll(

            ComboBox2_1.SelectedItems,

            {

                

Claims: "i:0#.f|membership|" & Lower(Mail),

                Department: "",

                DisplayName: DisplayName,

                Email: Mail,

                JobTitle: ".",

                Picture: "."

            }

        )

    }

);

 

Lastly an example of combining the single and multiple patch as a single patch

 

Patch(

    'Test List',

    LookUp(

        'Test List',

        ID = varItem.ID

    ),

    {

        PersonSingle: {

            Claims: "i:0#.f|membership|" & Lower(ComboBox1.Selected.Mail),

            Department: "",

            DisplayName: ComboBox1.Selected.DisplayName,

            Email: ComboBox1.Selected.Mail,

            JobTitle: "",

            Picture: ""

        },

        PersonMultiple: ForAll(ComboBox2_1.SelectedItems,{

                    Claims: "i:0#.f|membership|" & Lower(Mail),

                Department: "",

                DisplayName: DisplayName,

                Email: Mail,

                JobTitle: ".",

                Picture: "."

        })     

    }

);

1 ACCEPTED SOLUTION

Accepted Solutions
StalinPonnusamy
Super User
Super User

Hi @sasrsc1966 

 

  1. Person field in Office365 and Sharepoint stores in a different way. Both objects are different.
  2. Default Selected items depend on Items property.
    1. If the items property is Sharepoint then DefaultSelectedItems should be 

      {

          Claims:"i:0#.f|membership|"

    2. If you use Items property as Office365 then DefaultSelectedItems should be Office365Users.SearchUser
  3. SP uses a property called Email but Office365 uses Mail.


Thanks,
Stalin - Learn To Illuminate

View solution in original post

1 REPLY 1
StalinPonnusamy
Super User
Super User

Hi @sasrsc1966 

 

  1. Person field in Office365 and Sharepoint stores in a different way. Both objects are different.
  2. Default Selected items depend on Items property.
    1. If the items property is Sharepoint then DefaultSelectedItems should be 

      {

          Claims:"i:0#.f|membership|"

    2. If you use Items property as Office365 then DefaultSelectedItems should be Office365Users.SearchUser
  3. SP uses a property called Email but Office365 uses Mail.


Thanks,
Stalin - Learn To Illuminate

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (2,846)