cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
eTheory
Frequent Visitor

Show form in either edit mode and new mode based on items in list

Hi There

 

I have two sharepoint lists ListA and ListB. ListB has a lookup field to JobNumber in ListA.

I have created a powerapp that displays the ListA in a gallery when the item is selected in the gallery I want to show the form either with the edit mode (If a record already exists in ListB) or new mode (If there is not yet a record in ListB using that particular JobNumber).

I am unsure of how I can display the form in either edit or new mode based on items in ListB

 

I have tried doing an IF statemtent on the DefaultMode of the form along the lines of:

If(IsBlack(LookUp('ListB', JobNumber=gallery1.selected.JobNumber)), FormMode.New, FormMode.Edit)

 

 

However I get an invalid argument error. I have also tried searching for a solution but have been unsuccessful.

Any help would be much appreciated.

 

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisR
Resolver III
Resolver III

ISBlank is looking for a value, the lookup is returning a record.

 

To help with your formula, if JobNumber is the Lookup Column name in ListB, try something like this:

 

If(IsBlank(LookUp('ListB',Gallery1.Selected.ID = JobNumber.Id,JobNumber.Id)),FormMode.New, FormMode.Edit)

 

View solution in original post

4 REPLIES 4
CMee
Resolver I
Resolver I

You could simplify your formula by using the 'in' operator:

 

if(Gallery1.Selected.JobNumber in ListB.JobNumber, FormMode.Edit, FormMode.New)

 

eTheory
Frequent Visitor

Thanks for this however I am getting the following error "Cannot automatically convert this Text value to a Record"

Is this because gallery1.selected.JobNumber is a text field whereas ListB.JobNumber is a lookup?

ChrisR
Resolver III
Resolver III

ISBlank is looking for a value, the lookup is returning a record.

 

To help with your formula, if JobNumber is the Lookup Column name in ListB, try something like this:

 

If(IsBlank(LookUp('ListB',Gallery1.Selected.ID = JobNumber.Id,JobNumber.Id)),FormMode.New, FormMode.Edit)

 

eTheory
Frequent Visitor

Awesome. Thank you that worked and was exactly what I was after.

Much apprciated.

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.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (3,028)