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

Notifications

Announcements

Community site session details

Community site session details

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

Opening a Form in Edit or New mode depending on criteria

(1) ShareShare
ReportReport
Posted on by 708

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
    708 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
    708 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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard