cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
pricey79
Helper IV
Helper IV

Help with IF statement in a Form Please

Hello everyone, I was hoping someone could help.

 

I have a form and i want to set the default of a card to one thing depending on if the form is in edit mode, and something else if its in new mode.

This is what I have, but nothing happens. Can anyone please help?

 

If(
FormCTRP.Mode.Edit = true,
Gallery2.Selected.Title_Batch.Text,
FormCTRP.Mode.New = true,
Text_Search.Text
)

 

Thank you in advance

1 ACCEPTED SOLUTION

Accepted Solutions
BCLS776
Super User
Super User

Try this:

 

If(FormCTRP.Mode = FormMode.Edit, Gallery2.Selected.Title_Batch.Text,FormCTRP.Mode = FormMode.New,Text_Search.Text)

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

View solution in original post

3 REPLIES 3
BCLS776
Super User
Super User

Try this:

 

If(FormCTRP.Mode = FormMode.Edit, Gallery2.Selected.Title_Batch.Text,FormCTRP.Mode = FormMode.New,Text_Search.Text)

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

@BCLS776 

Thank you so much. That works. Thank you for saving my weekend!!

Drrickryp
Super User
Super User

@pricey79 

You can use the Coalesce() property to include the Parent.Default since this property will be blank if the form is new.  This can be put in the control's Default property inside the card.  If you did not want the user to be able to change it, then disable the card as well.  An alternative to disabling the card is to make the formula the Update property of the card and you can hide the card altogether.  I routinely do this when creating a foreign key from the ID in the parent gallery.  

 

Coalesce(Parent.Default,Text_Search.Text)

 

 

 

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

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

Users online (1,678)