How can I pre-populate a person/group field in my form to display current logged in user in a combo box?
I've tried using the formula below but the user name does not appear on the view page or even when I want to edit the form the name is not there, also checked on the sharepoint list to see whether the name has been saved on the list and it hasn't, not quite sure what to do there
If(
Form1.Mode=FormMode.New,
{
Claims: "i:0#.f|membership|" & User().Email,
DisplayName: User().FullName
}
Solved! Go to Solution.
Hi @SandraAkujobi ,
Ok, so you mean this form's mode maybe new or display or edit?
If so, you just need to add the result when mode is display or edit.
Try to set the combo box's DefaultSelectedItems like this:
If(
Form1.Mode=FormMode.New,
{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Claims:"i:0#.f|membership|" & User().Email,
Department:"",
DisplayName:User().FullName,
Email:User().Email,
JobTitle:"",
Picture:""
},
ThisItem.fieldname)
//please replace with your person field name
Best regards,
Hi @SandraAkujobi ,
Do you want the combo box for person field display as current user if the form's mode is new?
Could you tell me whether this person field allow multiple person?
If no, please set the combo box's DefaultSelectedItems like this:
If(
Form1.Mode=FormMode.New,
{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Claims:"i:0#.f|membership|" & User().Email,
Department:"",
DisplayName:User().FullName,
Email:User().Email,
JobTitle:"",
Picture:""
})
If yes, please set the combo box's DefaultSelectedItems like this:
If(
Form1.Mode=FormMode.New,
Table( {'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Claims:"i:0#.f|membership|" & User().Email,
Department:"",
DisplayName:User().FullName,
Email:User().Email,
JobTitle:"",
Picture:""
}))
Best regards,
@v-yutliu-msft It worked but the only problem is that it doesn't display the name of the employee on the detailed/edit page. Also the field does not allow multiple person.
Hi @SandraAkujobi ,
Ok, so you mean this form's mode maybe new or display or edit?
If so, you just need to add the result when mode is display or edit.
Try to set the combo box's DefaultSelectedItems like this:
If(
Form1.Mode=FormMode.New,
{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Claims:"i:0#.f|membership|" & User().Email,
Department:"",
DisplayName:User().FullName,
Email:User().Email,
JobTitle:"",
Picture:""
},
ThisItem.fieldname)
//please replace with your person field name
Best regards,
User | Count |
---|---|
183 | |
123 | |
88 | |
45 | |
42 |
User | Count |
---|---|
254 | |
160 | |
126 | |
78 | |
73 |