cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous
Not applicable

Prevent field from auto populating when a second user edits the form

Hi everyone,
 
I'm trying to figure out a way to prevent a field in a PowerApps form to auto populate when a second user edits the form. Ie, I only want the fields to auto populate when a new item is created, but not when a second user comes along and edits it.
 
Does that make sense? If so, if anyone has any insight on how to make this happen, I'd greatly appreciate it. 🙂
1 ACCEPTED SOLUTION

Accepted Solutions
tchin-nin
Level 10

Re: Prevent field from auto populating when a second user edits the form

For this last part, just type in "ThisItem." and you'll see some suggestions, just chose to the column where the Employee name is stored, it looks to be the Title so :

If(SharePointForm1.Mode=FormMode.New,User().FullName,ThisItem.Title)

ThisItem reference the Item displayed when Viewing or Editing one. With the "." You'll access all it's properties, so if the employee name is stored in the Title property, you want to display ThisItem.Title

 

Théo

 

 

View solution in original post

10 REPLIES 10
tchin-nin
Level 10

Re: Prevent field from auto populating when a second user edits the form

Hi @Anonymous

 

You can use the Form.Mode property to know when the form is for a new item or when it's an edition of an existing item. For example my list has a TextField column, I want the text input to be "Default value for new item" when I create a new item, but when I open the item to edit it, i want the textinput to have the value I have filled during the creation (or previous edition) :

 

textInput.Default : If(EditForm1.Mode=FormMode.New,"Default value for new item",ThisItem.TextField)

 

The FormMode can have 3 different value : New / Edit / View, you can play with that to have different behavior on creation / edition / view

 

Théo

Anonymous
Not applicable

Re: Prevent field from auto populating when a second user edits the form

Hi @tchin-nin,

 

Thanks for the response!

 

So for the Default property of the text input field, when I input: If(EditForm1.Mode=FormMode.New,Text(User().FullName),ThisItem.TextField)

 

I receive an error, stating "Invalid argument type".

 

I'm trying to get it to populate the user's Name automatically. It works when I just use Text(User().FullName) by itself, but not when I insert it into the above string.

 

Any idea on what is going on? I am still researching also. Thanks again!

tchin-nin
Level 10

Re: Prevent field from auto populating when a second user edits the form

If(EditForm1.Mode=FormMode.New,Text(User().FullName),ThisItem.TextField)

EditForm1 needs to be replaced by the name of your Form control.

TextField needs to be replaced by the property of the item where you store the user name. 

Also, User().FullName already returns a text, you don't need to use the Text() function.

 

Théo

 

 

Anonymous
Not applicable

Re: Prevent field from auto populating when a second user edits the form

Hi again @tchin-nin,

 

Thanks for the clarification. That makes sense.

 

I'm sorry I'm still struggling with this. I feel like I'm really close to getting it working.

 

Just to provide some more details, please take a look at the attached screenshot.

 

I fixed EditForm1 to reflect my Form control, which is SharePointForm1. I also changed the Textfield to reflect the Text Input field, which is DataCardValue1.

 

I'm not getting the error, "Name isn't valid. This identifier isn't recognized. This error appears most commonly when a formula refers to something that no longer exists."

 

Any thoughts as to what I'm doing wrong? I really do appreciate your help with this.

 

Anonymous
Not applicable

Re: Prevent field from auto populating when a second user edits the form

Also, thanks for letting me know that User().FullName returns text. Also made that correction. 🙂 

Anonymous
Not applicable

Re: Prevent field from auto populating when a second user edits the form

Okay, sorry, this is an update, but when I used:

 

If(SharePointForm1.Mode=FormMode.New,User().FullName)

 

It worked and auto-populated the name of the user that created the new item. However, when a different user opens up and edits the same item, the Employee Name area is erased and no text is there. 

 

Do you know of a way to prevent the Name text from being erased when a second user edits the form? I imagine there might be something to put at the end of the above string to prevent that?

 

tchin-nin
Level 10

Re: Prevent field from auto populating when a second user edits the form

If(SharePointForm1.Mode=FormMode.New,User().FullName)

That mean If this is a form for a new item, then put the current user full name into my text input.

So this is good ! But you need to add a third parameter to the if function: what to put in the textInput if the form in a New mode (meaning if it's on a Edit or View mode for an existing Item)

So for an existing item you need to set the text input value to the current value of the text property (I don't know the name of this property for you). For example if you data source is SharePoint then you'll use the name of the column where you store the user full name.

If(SharePointForm1.Mode=FormMode.New,User().FullName,ThisItem.TextColumn)

Using the "ThisItem." let you retrieve the value of the properties of the item displayed in the form.

Théo

Anonymous
Not applicable

Re: Prevent field from auto populating when a second user edits the form

I really appreciate your help, but for whatever reason, I am just not able to get this last part. I understand that you're saying for the last part of the string, I need to tell it what to do if it's not a New form, but Edit or View. No matter what combination of things I input, I can't seem to get it to cooperate.

 

I attached a screenshot of the fields and such in my previous post. Would that help figure out what I'm missing? Again, can't thank you enough for taking all this time to help me muddle through this. 🙂 

tchin-nin
Level 10

Re: Prevent field from auto populating when a second user edits the form

For this last part, just type in "ThisItem." and you'll see some suggestions, just chose to the column where the Employee name is stored, it looks to be the Title so :

If(SharePointForm1.Mode=FormMode.New,User().FullName,ThisItem.Title)

ThisItem reference the Item displayed when Viewing or Editing one. With the "." You'll access all it's properties, so if the employee name is stored in the Title property, you want to display ThisItem.Title

 

Théo

 

 

View solution in original post

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (5,801)