cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
VJR
Super User
Super User

Change caption based on modes

Hello members,

 

This seems pretty simple but unable to achieve the desired results.

Could you assist what's going wrong.

 

- Screen 1 is a homepage with a Button1 called NEW and Gallery1 with a list of items

 

 

- Screen 2 is a View Detail Screen. This has a button called CHANGE to modify a record.

 

 

- This is an EditForm on Screen 3

VJR_0-1661489085452.png

 

 

I want to change the caption of the title to "New Form" based on whether a user has arrived to Screen 3 via the NEW button from Screen 1

OR

set to "Edit Form" if user has arrived via the CHANGE button of Screen 2.

 

NEW Button has -> NewForm(EditForm1);Navigate(Screen3);

CHANGE button has -> EditForm(EditForm1);Navigate(Screen3);

 

On all cases I am getting the Form mode as Edit and never as New, hence unable to write a formula accordingly.

 

Please advise.

 

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
Masino
Super User
Super User

Ok i got it now, let me know if it works.

If(Editform1.Mode=FormMode.Edit;"edit";"new")

 or..

If(Editform1.Mode=FormMode.Edit;"edit";If(Editform1.Mode=FormMode.New;"New";If(Editform1.Mode=FormMode.View;"View")))

View solution in original post

9 REPLIES 9
Masino
Super User
Super User

 New form and Edit form are actually the same thing.. It is read as edit.
When you write :   If(Editform1.DisplayMode ="edit" , "EditForm, "NewForm") ,      it will always show editform,of course.

I can suggest to create a variable that activates when you click on that "New"button.

Hope it will help

Hello @Masino 

Thanks for your reply.

If New form and Edit form are same how does it know whether to Add a new record or Edit an existing one using the same button while saving a Form?

 

Masino
Super User
Super User

NewForm and EditForm are exactly the same.
With newform you insert new data into a blank line ( if we think this way), and with editform you edit an existing line ( thats why you have to "select" what you have to edit).

 

UPDATE: OK , i got you now, FormMode... sorry, my mistake! I hope the solution below will help anyways ! 😉

 

My solution is to create a variable that becomes true when you click on the "new" button. 

So your formula would be,

new button from screen1  : Onselect : set(xxx, true)

back from screen 3 ( or whatever you want) : set(xxx, false)

on the label text: If(xxx = true , "newForm", "editForm")

 

 

Hope this will help you

Masino
Super User
Super User

Gotcha...

If(Editform1.Mode ="edit" , "EditForm, "NewForm")

 

If(Editform1.Mode.Edit = true , "EditForm, "NewForm")

 

😉

@Masino , I had compared using the .Mode prior to posting here and both the above statements are throwing the incompatible comparison error (enum versus text).

 

VJR_0-1661499878455.png

 

I had the variable option in mind, but I had read that the Form modes automatically change to New or Edit depending on whether NewForm or EditForm are called respectively.

 

Any solutions other than variable, please share. 

Masino
Super User
Super User

have you tried to use 

If(EditForm1.Mode.Edit = true , "EditForm, "NewForm")
with the big F?
As i can see in your image it has not been recognized ( you know, the colour of the function) . 

As you can see i don't get this error.....
sssssss.jpg

 

If i got any solution i'll write here

VJR
Super User
Super User

Typo on my side with the F, but still shows the incompatibility in comparison.

It is giving New Form in both the cases (New or Edit)

 

The yellow mark that is seen in your screenshot too gives the below.

 

VJR_0-1661501328138.png

 

Masino
Super User
Super User

Ok i got it now, let me know if it works.

If(Editform1.Mode=FormMode.Edit;"edit";"new")

 or..

If(Editform1.Mode=FormMode.Edit;"edit";If(Editform1.Mode=FormMode.New;"New";If(Editform1.Mode=FormMode.View;"View")))

VJR
Super User
Super User

@Masino 

If(Editform1.Mode=FormMode.Edit;"edit";"new")

is working as expected.

 

I will share another option for anyone landing on this thread

If(Value(Editform1.Mode) = 0 ;"edit";"new")

 

0 is for Edit

1 is New

2 is View

 

 

Thanks :).

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (1,574)