sharepoint-onlinepowerapps

Show the current logged on user in a combo box on a new form and the SharePoint value when editing the form


In a combo box, how do I show the currently logged-on user if the form is NEW and if it's not new show the information from the SharePoint list?

I have this formula on the DefaultSelectedItems of the Combo box:

If(EditForm1.Mode=FormMode.New,
    Office365Users.MyProfile(),
    ThisItem.SharepointColumn
)

But this gives me an error on the entire formula.

I've tried many different variations on many different properties, but I can seem to get the current user to display on a new form and the SharePoint value to display when editing a form.


Solution

  • If your SharePoint column is a text field, you need to use one of the properties of the MyProfile result, as the two options in the If function need to be compatible with each other. For example:

    If(EditForm1.Mode=FormMode.New,
        Office365Users.MyProfile().DisplayName,
        ThisItem.SharepointColumn
    )
    

    or

    If(EditForm1.Mode=FormMode.New,
        Office365Users.MyProfile().Mail,
        ThisItem.SharepointColumn
    )
    

    Or any other text column from the profile.