cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
Community Support
Community Support

Re: Windows365Users Default User / SP List

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
Highlighted
Community Support
Community Support

Re: Windows365Users Default User / SP List

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

Highlighted
Frequent Visitor

Re: Windows365Users Default User / SP List

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

Highlighted
Community Support
Community Support

Re: Windows365Users Default User / SP List

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

Frequent Visitor

Re: Windows365Users Default User / SP List

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
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors
Users online (7,561)