Skip to main content

Notifications

Power Apps - Building Power Apps
Suggested answer

Form Modes

(1) ShareShare
ReportReport
Posted on by 19
I am building an app that in theory will open the existing record on the SP list if it exists.  If it does not exist I can add a new record.  
 
This is what I have in the form Item:  
 
If(IsBlank(LookUp(Gate1,ThisRecord.ID = galProjects.Selected.ID)),FormMode.New)
 
What am I missing?
 
Thanks in advance for any and all guidance!
Kim
  • timl Profile Picture
    timl 33,744 on at
    Form Modes
     
    If none of the fields are loading on the form, I'd suggest going to the Fields link in the properties of the form and re-adding the cards for the fields. That should reset things and may help.  
  • Khibby Profile Picture
    Khibby 19 on at
    Form Modes
    Yes, that's correct.  
     
    Button on Screen1 - OnSelect: 
    If(IsBlank(LookUp(Gate1, ProjectID.Value = galProjects.Selected.ProjectID)), NewForm(frmGate1), EditForm(frmGate1));Navigate('Gate-1')
     
    Form on Screen2 (frmGate1) Item:
    LookUp(Gate1, ProjectID.Value = galProjects.Selected.ProjectID)
     

    Thank you for your continued support on this! It's much appreciated.
    Kim
  • timl Profile Picture
    timl 33,744 on at
    Form Modes
    >> However, my form isn't loading the data that exists on Gate1.  
     
    With regards to this issue, have you set the Item property of your form to this?
     
    LookUp(Gate1, ProjectID.Value = galProjects.Selected.ProjectID)
     
  • Khibby Profile Picture
    Khibby 19 on at
    Form Modes
    I was able to fix the error by changing SP column to ProjectID.Value.  So the whole thing is: 
     
    If(IsBlank(LookUp(Gate1, ProjectID.Value = galProjects.Selected.ProjectID)), NewForm(frmGate1), EditForm(frmGate1));Navigate('Gate-1')
     
    However, my form isn't loading the data that exists on Gate1.  
  • Khibby Profile Picture
    Khibby 19 on at
    Form Modes
    I've tried this method but keep getting a type mismatch error.  This is what I have OnSelect of the button:
    If(IsBlank(LookUp(Gate1, ProjectID = galProjects.Selected.ProjectID)), NewForm(frmGate1), EditForm(frmGate1))
     
    Apparently the data type in the Gate1 list is text and the gallery holds records.  How do I tell it to search the record for that text string?  
  • Suggested answer
    Mitanshu Profile Picture
    Mitanshu 1,604 on at
    Form Modes

    The FormMode.New is not a valid value for the Item property. Instead, Item expects a specific record or Blank() to determine whether the form will open an existing record or allow creating a new one.

    Item property of Form:

    If(
        IsBlank(LookUp(Gate1, ID = galProjects.Selected.ID)),
        Blank(),
        LookUp(Gate1, ID = galProjects.Selected.ID)
    )

    Setting Form Mode

    To determine whether the form should be in New or Edit mode, use the OnVisible or OnSelect property of your screen or button to set the form's mode explicitly.

    If(
        IsBlank(LookUp(Gate1, ID = galProjects.Selected.ID)),
        NewForm(Form1),
        EditForm(Form1)
    )
  • Suggested answer
    Pstork1 Profile Picture
    Pstork1 64,722 on at
    Form Modes
    I think you want IsEmpty() instead of IsBlank(). Is Blank is used with a string, Is Empty is used with a record or table. The output of your Lookup is a record, not a string.  It would also work if you have the Lookup return a single string field like Title.  Like this
    If(IsBlank(LookUp(Gate1,ThisRecord.ID = galProjects.Selected.ID,Title)),FormMode.New)

    ----------------------------------------------------------------------------------
    If this Post helped you, please click "Does this answer your question" and give it a like to help others in the community find the answer too!

    Paul Papanek Stork, MVP
    Blog: https://www.dontpapanic.com/blog
     

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,434

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,722

Leaderboard