cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
GoGorilla
Helper III
Helper III

Get user email and store in text field only if form mode is new, else hold that value in the field

I have a canvas app with a SharePoint list as a data source. When a user creates a new item in the canvas app (FormMode = New), I want to get their email and store it in a text field called txtUserEmail or a PeoplePicker called UserEmail.  When an approver opens that same existing app, I want the original user's email to be populated in the txtUserEmail or UserEmail field and not show as empty.

 

I have tried the following formula in the default of the data card for the people picker UserEmail:

If(FormMode = New,
  {Email:User().Email
  }
  ,Parent.Default
)

Data Card Update Property of people picker UserEmail:

If(
    FormMode = New,
    {Email: User().Email
    },
    UserEmailDataCard.Selected
)
    

 

I have tried the following in the txtUserEmail Default property but I get "The function IF has some invalid properties. I did try to convert the User Email to text, as well:

If(FormMode = New,
  Office365Users.UserProfileV2(User().Email),
  Parent.Default
  )

  I have tried the following in the txtUserEmail Update property but get the same error as above. 

If(FormMode = New,
  Office365Users.UserProfileV2(User().Email),
 txtUserEmailDataCardValue.Text
  )

 

Any assistance is welcomed.  Thank you in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Alex_10
Super User
Super User

@GoGorilla 

 

yes, txtUserEmail's parent must be the form.

i was confused with FormMode.

can you try:

 

txtUserEmail.Default = Parent.Default

txtUserEmailDataCardValue.Default = 
If(YOURformNAME.Mode = FormMode.New,
  User().Email,
  Parent.Default
)

txtUserEmail.Update = txtUserEmailDataCardValue.Text

Does email get saved in SharePoint when you submit a new form?

 

View solution in original post

4 REPLIES 4
Alex_10
Super User
Super User

@GoGorilla 

 

If txtUserEmail is the datacard's name and txtUserEmailDataCardValue is the text input's name inside txtUserEmail:

txtUserEmail.Default = Parent.Default

txtUserEmailDataCardValue.Default = 
If(FormMode = New,
  User().Email,
  Parent.Default
)

txtUserEmail.Update = txtUserEmailDataCardValue.Text

@Alex_10 Thank you for your input.  The txtUserEmail field is not populating at all.  I tried your formula but it doesn't populate.  Although, I did change the default property of the data card to Parent.Default, I changed it back to a default property of txtUserEmail as ThisItem.txtUserEmail since it is the data card.  Parent.Default does not work there.  The parent of the data card is the form, correct?

Alex_10
Super User
Super User

@GoGorilla 

 

yes, txtUserEmail's parent must be the form.

i was confused with FormMode.

can you try:

 

txtUserEmail.Default = Parent.Default

txtUserEmailDataCardValue.Default = 
If(YOURformNAME.Mode = FormMode.New,
  User().Email,
  Parent.Default
)

txtUserEmail.Update = txtUserEmailDataCardValue.Text

Does email get saved in SharePoint when you submit a new form?

 

GoGorilla
Helper III
Helper III

@Alex_10  The FormMode.New worked.  The only difference is that the txtUserEmail.Default should be ThisItem.txtUserEmail.  Thank you.

Helpful resources

Announcements
Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Government Carousel

New forum: GCC, GCCH, DoD - Federal App Makers (FAM)

In response to the unique and evolving requirements of the United States public sector, Microsoft has created Power Apps US Government.

Users online (2,006)