web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Opening a Form in Edit...
Power Apps
Answered

Opening a Form in Edit or New mode depending on criteria

(1) ShareShare
ReportReport
Posted on by 728

Hi

 

I am trying to open a form in either Edit Form or New Form depending on the criteria.  I have 2 SP Lists, one that stores client details and the other will store costings.

 

These lists are linked with the ID number of the client list and MasterID column in the costings list.

 

What I would like the button to do is, if there is a record in the costings list that has a matching number in its MasterID column, then the form is to open in EditForm with the details showing.

 

However, if there is no record in the costings list that relates to the selected client, then the form is to open in NewForm.

 

This is the formula that i have tried:

 

Set(MasterID, LookUp(LDR_Enquiry_Costs, MasterID = varRequest.ID));
If(
 IsEmpty(MasterID),
 NewForm(Form3),
 EditForm(Form3));
 Navigate(Screen1,ScreenTransition.None)

 

There is currently no data in the costings list so the form should open blank but i just get the no item to display message.

 

Any suggestions on how i can fix this please?

 

thanks

Categories:
I have the same question (0)
  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at

     

    //put the below Set on the OnVisible of Screen1 
    Set(MasterID, LookUp(LDR_Enquiry_Costs, MasterID = varRequest.ID));
    //
    
    //now put the below in the DefaultMode property of the Form control itself
    If(
     IsEmpty(MasterID),
     FormMode.New,
     FormMode.Edit
    )

     

    More detail:

    EditForm, NewForm, DefaultMode, FormMode, FormMode.New, FormMode.Edit

     

  • neill_long Profile Picture
    728 on at

    @poweractivate 

     

    On the button, which is on another screen, I assume, this would just have the navigate(....)?

     

    On my test, if there is a record in the SP list, the form does open in EditForm, but if there isn't a match, it is still displaying the no item to display.

     

    I can add a plus button and put newform(formname) but was hoping I could get it to open if empty.

     

     

  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    @neill_long 

     

    //put the below Set on the OnVisible of Screen1 
    Set(varMasterID, LookUp(LDR_Enquiry_Costs, MasterID = varRequest.ID));
    //
    
    //now put the below in the DefaultMode property of the Form control itself
    If(
     IsEmpty(varMasterID),
     FormMode.New,
     FormMode.Edit
    )
    
    //now put the below in the Item property of the Form control itself
    If(
     IsEmpty(varMasterID),
     Defaults(yourDataSourceName),
     varMasterID
    )

    See if it helps @neill_long 

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @neill_long 

    Try IsBlank instead of IsEmpty

  • Verified answer
    poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    @Drrickryp is right. A LookUp returns a single Record, not a Table, so you should use IsBlank @neill_long 

     

    //put the below Set on the OnVisible of Screen1 
    Set(varMasterID, LookUp(LDR_Enquiry_Costs, MasterID = varRequest.ID));
    //
    
    //now put the below in the DefaultMode property of the Form control itself
    If(
     IsBlank(varMasterID),
     FormMode.New,
     FormMode.Edit
    )
    
    //now put the below in the Item property of the Form control itself
    If(
     IsBlank(varMasterID),
     Defaults(yourDataSourceName),
     varMasterID
    )

     

    IsEmpty would only be correct, if it was Filter (which returns a Table) rather than LookUp (which returns a single Record)

     

    See if it helps @neill_long 

  • neill_long Profile Picture
    728 on at

    @poweractivate  & @Drrickryp  thank you.  Got it to work.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 530

#2
WarrenBelz Profile Picture

WarrenBelz 459 Most Valuable Professional

#3
Haque Profile Picture

Haque 314

Last 30 days Overall leaderboard