cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SteveRoach
Frequent Visitor

Windows365Users Default User / SP List

Hi Guys,

 

I have a SP List with a column 'Person' having the Datatype Person. I recently got some help on this forum as to how to write Windows365User records to the List and this works fine. This App was built using the 'Start from data' method with the SP List as the starting point. I have also added the 'Windows 365 Users' data source to the App.

 

This is how I would like the App to behave:

 

Create Mode:

  • The Person field defaults to the logged in User. If the User submits the form, the User is written to the List.
  • The logged in User can override them self with any other User from the Windows365Users combo list. When the User submits the form, the override User is written to the List.

Edit Mode:

  • The Person field is populated with the User extracted from the List. The logged in User can update any fields and if they leave the extracted User as-is, the List value is left unchanged after a Submit.
  • The logged in User can override the List User with them self or any other User from the Windows365Users combo list. The updated User is written to the SP List.

 

My Configuration:

EditScreen1> EditForm1:

  • Person_DataCard2:
    • Advanced:
      • Default: ThisItem.Person
      • Update:
        • If(EditForm1.Mode = FormMode.New,{
              DisplayName:User().FullName,
              Claims:"i:0#.f|membership|" & Lower(User().Email),
              Department:"",
              Email:User().Email,
              JobTitle:"",
              Picture:""
          },DataCardValue4.Selected)
    • DataCardValue4:
      • Advanced:
        • Items:
          • Microsoft365Users.SearchUser({searchTerm : "", top:999})
        • DefaultSelectedItems:
          • If(EditForm1.Mode = FormMode.New, {
                DisplayName:User().FullName,
                Claims:"i:0#.f|membership|" & Lower(User().Email),
                Department:"",
                Email:User().Email,
                JobTitle:"",
                Picture:""
            }, ThisItem.Person)

What works/what doesn't:

 

Create Mode:

  • The Person field defaults to the logged in User. If the User submits the form, the User is written to the List.
    • Good
  • The logged in User can override them self with any other User from the Windows365Users combo list. If the User submits the form, the override User is written to the List.
    • FAIL: An override User can be chosen from the combo list but, after it has been submitted, the logged in User is stored rather than the override.

Edit Mode:

  • The Person field contains the User extracted from the List. The User can update any fields and if they leave the extracted User as-is, the List value is left unchanged after a Submit.
    • GOOD
  • The logged in User can override the List User with them self or any other User from the Windows365Users combo list. The updated User is written to the SP List.
    • FAIL: Regardless of what User is chosen to override the stored value, the stored value is not updated.

Any suggestions would be appreciated.

 

TIA

 

Steve

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-siky-msft
Community Support
Community Support

Hi @SteveRoach ,

 

 

The issue is caused that the login user is hard coded in Update property of data card so it always saves the login user to SP list.

The workaround is to modify the Update property as follows.

{
    DisplayName:DataCardValue4.Selected.DisplayName,
    Claims:"i:0#.f|membership|" & DataCardValue4.Selected.UserPrincipalName,
    Department:"",
    Email:DataCardValue4.Selected.UserPrincipalName,
    JobTitle:"",
    Picture:""
}

 

Beyond that, I would recommend you modify the DefaultSelectedItems as follows.

If(
EditForm1.Mode = FormMode.New,
LookUp(Microsoft365Users.SearchUser({searchTerm : "", top:999}), UserPrincipalName=User().Email),
LookUp(Microsoft365Users.SearchUser({searchTerm : "", top:999}), UserPrincipalName=ThisItem.Person.Email)
)

Hope this helps.

Sik

View solution in original post

4 REPLIES 4
v-siky-msft
Community Support
Community Support

Hi @SteveRoach ,

 

 

The issue is caused that the login user is hard coded in Update property of data card so it always saves the login user to SP list.

The workaround is to modify the Update property as follows.

{
    DisplayName:DataCardValue4.Selected.DisplayName,
    Claims:"i:0#.f|membership|" & DataCardValue4.Selected.UserPrincipalName,
    Department:"",
    Email:DataCardValue4.Selected.UserPrincipalName,
    JobTitle:"",
    Picture:""
}

 

Beyond that, I would recommend you modify the DefaultSelectedItems as follows.

If(
EditForm1.Mode = FormMode.New,
LookUp(Microsoft365Users.SearchUser({searchTerm : "", top:999}), UserPrincipalName=User().Email),
LookUp(Microsoft365Users.SearchUser({searchTerm : "", top:999}), UserPrincipalName=ThisItem.Person.Email)
)

Hope this helps.

Sik

View solution in original post

Hi Sik,

 

Thanks for that - Create mode is working perfectly now.

 

However, Edit Mode isn't quite right:

 

Edit Mode:

  • The Person field contains the User extracted from the List. The User can update any fields and if they leave the extracted User as-is, the List value is left unchanged after a Submit.
    • GOOD
  • The logged in User can override the List User with them self or any other User from the Windows365Users combo list. The updated User is written to the SP List.
    • FAIL: Regardless of what User is chosen to override the stored value, the stored value is not updated.

 

I have changed the DefaultSelectedItems, as you suggested, to:

 

If(
EditForm1.Mode = FormMode.New,
LookUp(Microsoft365Users.SearchUser({searchTerm : "", top:999}), UserPrincipalName=User().Email),
LookUp(Microsoft365Users.SearchUser({searchTerm : "", top:999}), UserPrincipalName=ThisItem.Person.Email)
)

 

It appears that the second part of this If statement (where EditForm1.Mode is not FormMode.New) isn't picking up that I have changed the field. Or, if it has, it isn't searching the Microsoft365Users list for the change.

 

Any ideas?

 

Cheers

 

Steve

Hi @SteveRoach ,

 

The issue sounds like a error in Update property. 

Did you put my code in the original If logic? If so, it is not necessary, please put the following code to Update property directly. Whatever the form is to create or edit, the person to update is always from the DataCardValue4.

{
    DisplayName:DataCardValue4.Selected.DisplayName,
    Claims:"i:0#.f|membership|" & DataCardValue4.Selected.UserPrincipalName,
    Department:"",
    Email:DataCardValue4.Selected.UserPrincipalName,
    JobTitle:"",
    Picture:""
}

The DefaultSelectedItems property code is to display the default person in combobox. if the form is in create mode, it shows LoginUser by default, if in edit mode, it shows the person extracted from the List. Hence, it doesn't do with this issue.

Hope this helps.

Sik

Hi Sik,

 

Yes, that worked very well. My bad, I misinterpreted your first about the DataCardValue Update property. This all works as expected, thank you.

 

Steve

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (1,207)