cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
pn1995
Helper I
Helper I

Auto populate default value

Hi

We have a drop down field were user can select a location

 

We then have a another field for a ticket reference were depending on the location select, a code is entered is automatically populated and the user is then allowed to add to this eg

 

Location DropDown has the option "Basingstoke-(BAS)", Other options

Ticket referernce would automatically add "BAS-" (because Basingstoke-(BAS) was selected in Location

 

User can then append to BAS- with a reference number, thus making the "Ticket Reference" "BAS-1234"

 

We have in the "Ticket Reference" Default field this formula...


If(DataCardValue4.Selected.Value="Basingstoke-(BAS)","BAS-","false")

 

This work fine, as saves ok into a SharePoint List.

 

However when you "Edit" the form again it loses the saved data (eg BAS-1234) and reverts back to "BAS-"

 

Any idea how to get the Edited form to keep the data that is saved?

 

Thanks

 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@pn1995 

Your issue is in the Default property.  You need to check to see if the form is in New mode or Edit mode.

If it is in New mode, then you want the formula you have to function.

If it is in Edit mode, then you want to use the value in the data column.

 

If(yourForm.Mode=FormMode.New, 
    If(DataCardValue4.Selected.Value="Basingstoke-(BAS)","BAS-","false"),
Parent.Default
)

Of course - I'm a little suspect on the If statement you have now.  This will say that the default value will be "BAS-" or "false".  Not sure that's what you want.

But, this will help you display the actual field value when you are not in New mode (i.e. Display and Edit)

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

1 REPLY 1
RandyHayes
Super User
Super User

@pn1995 

Your issue is in the Default property.  You need to check to see if the form is in New mode or Edit mode.

If it is in New mode, then you want the formula you have to function.

If it is in Edit mode, then you want to use the value in the data column.

 

If(yourForm.Mode=FormMode.New, 
    If(DataCardValue4.Selected.Value="Basingstoke-(BAS)","BAS-","false"),
Parent.Default
)

Of course - I'm a little suspect on the If statement you have now.  This will say that the default value will be "BAS-" or "false".  Not sure that's what you want.

But, this will help you display the actual field value when you are not in New mode (i.e. Display and Edit)

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

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 (1,989)